Compare commits
18 Commits
72f737c370
...
feature/71
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4099756d15 | ||
|
|
133eac4a5c | ||
|
|
91bad533c3 | ||
|
|
f5ed94866b | ||
|
|
b70f280c6e | ||
|
|
9922402b3b | ||
|
|
152657e41b | ||
|
|
0a79a4e336 | ||
|
|
174af13a58 | ||
|
|
00922e3674 | ||
|
|
3b60db56de | ||
|
|
2a330a4bd8 | ||
|
|
579b7138e7 | ||
|
|
98f8430c45 | ||
|
|
912847ae33 | ||
|
|
33647fa3e0 | ||
|
|
d1f9f8cf8c | ||
|
|
7d1f7b11eb |
@@ -196,11 +196,14 @@ class SfProductionDemandPlan(models.Model):
|
|||||||
else:
|
else:
|
||||||
line.model_long = None
|
line.model_long = None
|
||||||
|
|
||||||
@api.depends('product_id.model_long', 'product_id.model_width', 'product_id.model_height')
|
@api.depends('product_id.model_long', 'product_id.model_width', 'product_id.model_height', 'product_id.blank_type')
|
||||||
def _compute_embryo_long(self):
|
def _compute_embryo_long(self):
|
||||||
for line in self:
|
for line in self:
|
||||||
if line.product_id:
|
if line.product_id:
|
||||||
line.embryo_long = f"{round(line.product_id.model_long, 3)}*{round(line.product_id.model_width, 3)}*{round(line.product_id.model_height, 3)}"
|
if line.product_id.blank_type == '圆料':
|
||||||
|
line.embryo_long = f"Ø{round(line.product_id.model_width, 3)}*{round(line.product_id.model_long, 3)}"
|
||||||
|
else:
|
||||||
|
line.embryo_long = f"{round(line.product_id.model_long, 3)}*{round(line.product_id.model_width, 3)}*{round(line.product_id.model_height, 3)}"
|
||||||
else:
|
else:
|
||||||
line.embryo_long = None
|
line.embryo_long = None
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
<field name="qty_delivered"/>
|
<field name="qty_delivered"/>
|
||||||
<field name="qty_to_deliver"/>
|
<field name="qty_to_deliver"/>
|
||||||
<field name="model_long"/>
|
<field name="model_long"/>
|
||||||
<field name="blank_type"/>
|
<field name="blank_type" optional="hide"/>
|
||||||
<field name="embryo_long"/>
|
<field name="embryo_long"/>
|
||||||
<field name="materials_id"/>
|
<field name="materials_id"/>
|
||||||
<field name="model_machining_precision"/>
|
<field name="model_machining_precision"/>
|
||||||
|
|||||||
@@ -707,9 +707,11 @@ class Sf_Dashboard_Connect(http.Controller):
|
|||||||
interval_plan_orders = plan_order_messages.filtered(
|
interval_plan_orders = plan_order_messages.filtered(
|
||||||
lambda o: o.create_date >= start_time
|
lambda o: o.create_date >= start_time
|
||||||
and o.create_date <= end_time
|
and o.create_date <= end_time
|
||||||
)
|
)
|
||||||
|
|
||||||
interval_orders = request.env['mrp.workorder'].sudo().browse(interval_plan_orders.mapped('res_id'))
|
interval_order_ids = set(interval_plan_orders.mapped('res_id'))
|
||||||
|
|
||||||
|
interval_orders = request.env['mrp.workorder'].sudo().browse(interval_order_ids)
|
||||||
if line == '业绩总览':
|
if line == '业绩总览':
|
||||||
interval_orders = interval_orders.filtered(lambda o: o.routing_type in ['人工线下加工', 'CNC加工'])
|
interval_orders = interval_orders.filtered(lambda o: o.routing_type in ['人工线下加工', 'CNC加工'])
|
||||||
elif line == '人工线下加工中心':
|
elif line == '人工线下加工中心':
|
||||||
@@ -862,33 +864,37 @@ class Sf_Dashboard_Connect(http.Controller):
|
|||||||
"""
|
"""
|
||||||
# res = {'status': 1, 'message': '成功', 'not_done_data': [], 'done_data': []}
|
# res = {'status': 1, 'message': '成功', 'not_done_data': [], 'done_data': []}
|
||||||
res = {'status': 1, 'message': '成功', 'data': {}}
|
res = {'status': 1, 'message': '成功', 'data': {}}
|
||||||
|
# 解决产品名称取到英文的问题
|
||||||
|
request.update_context(lang='zh_CN')
|
||||||
plan_obj = request.env['sf.production.plan'].sudo()
|
plan_obj = request.env['sf.production.plan'].sudo()
|
||||||
work_order_obj = request.env['mrp.workorder'].sudo()
|
work_order_obj = request.env['mrp.workorder'].sudo()
|
||||||
|
# 获取mrp.workorder的state字段的selection内容
|
||||||
|
state_dict = dict(request.env['mrp.workorder'].sudo()._fields['state'].selection)
|
||||||
line_list = ast.literal_eval(kw['line_list'])
|
line_list = ast.literal_eval(kw['line_list'])
|
||||||
begin_time_str = kw['begin_time'].strip('"')
|
begin_time_str = kw['begin_time'].strip('"')
|
||||||
end_time_str = kw['end_time'].strip('"')
|
end_time_str = kw['end_time'].strip('"')
|
||||||
begin_time = datetime.strptime(begin_time_str, '%Y-%m-%d %H:%M:%S')
|
begin_time = datetime.strptime(begin_time_str, '%Y-%m-%d %H:%M:%S')
|
||||||
end_time = datetime.strptime(end_time_str, '%Y-%m-%d %H:%M:%S')
|
end_time = datetime.strptime(end_time_str, '%Y-%m-%d %H:%M:%S')
|
||||||
# print('line_list: %s' % line_list)
|
# print('line_list: %s' % line_list)
|
||||||
not_done_data = []
|
|
||||||
done_data = []
|
|
||||||
final_data = {}
|
final_data = {}
|
||||||
not_done_index = 1
|
|
||||||
done_index = 1
|
|
||||||
|
|
||||||
# 获取当前时间,并计算24小时前的时间
|
# 获取当前时间,并计算24小时前的时间
|
||||||
current_time = datetime.now()
|
current_time = datetime.now()
|
||||||
time_48_hours_ago = current_time - timedelta(hours=48)
|
time_48_hours_ago = current_time - timedelta(hours=48)
|
||||||
|
|
||||||
# 计划量,目前只能从mail.message中筛选出
|
# # 计划量,目前只能从mail.message中筛选出
|
||||||
plan_order_messages = request.env['mail.message'].sudo().search([
|
# plan_order_messages = request.env['mail.message'].sudo().search([
|
||||||
('model', '=', 'mrp.workorder'),
|
# ('model', '=', 'mrp.workorder'),
|
||||||
('create_date', '>=', time_48_hours_ago.strftime('%Y-%m-%d %H:%M:%S')),
|
# ('create_date', '>=', time_48_hours_ago.strftime('%Y-%m-%d %H:%M:%S')),
|
||||||
('tracking_value_ids.field_desc', '=', '状态'),
|
# ('tracking_value_ids.field_desc', '=', '状态'),
|
||||||
('tracking_value_ids.new_value_char', 'in', ['就绪', '生产中'])
|
# ('tracking_value_ids.new_value_char', 'in', ['就绪', '生产中'])
|
||||||
])
|
# ])
|
||||||
|
|
||||||
for line in line_list:
|
for line in line_list:
|
||||||
|
not_done_data = []
|
||||||
|
done_data = []
|
||||||
|
not_done_index = 1
|
||||||
|
done_index = 1
|
||||||
|
|
||||||
if line == '业绩总览':
|
if line == '业绩总览':
|
||||||
work_order_domain = [('routing_type', 'in', ['人工线下加工', 'CNC加工'])]
|
work_order_domain = [('routing_type', 'in', ['人工线下加工', 'CNC加工'])]
|
||||||
@@ -904,16 +910,18 @@ class Sf_Dashboard_Connect(http.Controller):
|
|||||||
# [('production_line_id.name', '=', line), ('state', 'not in', ['finished']),
|
# [('production_line_id.name', '=', line), ('state', 'not in', ['finished']),
|
||||||
# ('production_id.state', 'not in', ['cancel', 'done']), ('active', '=', True)
|
# ('production_id.state', 'not in', ['cancel', 'done']), ('active', '=', True)
|
||||||
# ])
|
# ])
|
||||||
# not_done_orders = work_order_obj.search(work_order_domain +
|
not_done_orders = work_order_obj.search(work_order_domain + [
|
||||||
# [('state', 'in', ['ready', 'progress'])], order='id asc'
|
('state', 'in', ['ready', 'progress']),
|
||||||
# )
|
('date_planned_start', '>=', time_48_hours_ago)
|
||||||
not_done_orders = request.env['mrp.workorder'].sudo().browse(plan_order_messages.mapped('res_id'))
|
], order='id asc'
|
||||||
if line == '业绩总览':
|
)
|
||||||
not_done_orders = not_done_orders.filtered(lambda o: o.routing_type in ['人工线下加工', 'CNC加工'])
|
# not_done_orders = request.env['mrp.workorder'].sudo().browse(plan_order_messages.mapped('res_id'))
|
||||||
elif line == '人工线下加工中心':
|
# if line == '业绩总览':
|
||||||
not_done_orders = not_done_orders.filtered(lambda o: o.routing_type == '人工线下加工')
|
# not_done_orders = not_done_orders.filtered(lambda o: o.routing_type in ['人工线下加工', 'CNC加工'])
|
||||||
else:
|
# elif line == '人工线下加工中心':
|
||||||
not_done_orders = not_done_orders.filtered(lambda o: o.routing_type == 'CNC加工' and o.production_line_id.name == line)
|
# not_done_orders = not_done_orders.filtered(lambda o: o.routing_type == '人工线下加工')
|
||||||
|
# else:
|
||||||
|
# not_done_orders = not_done_orders.filtered(lambda o: o.routing_type == 'CNC加工' and o.production_line_id.name == line)
|
||||||
|
|
||||||
|
|
||||||
# 完成订单
|
# 完成订单
|
||||||
@@ -922,11 +930,11 @@ class Sf_Dashboard_Connect(http.Controller):
|
|||||||
# time_24_hours_ago = current_time - timedelta(hours=24)
|
# time_24_hours_ago = current_time - timedelta(hours=24)
|
||||||
|
|
||||||
finish_orders = work_order_obj.search(work_order_domain + [
|
finish_orders = work_order_obj.search(work_order_domain + [
|
||||||
('state', 'in', ['finished']),
|
('state', 'in', ['done']),
|
||||||
('production_id.state', 'not in', ['cancel']),
|
('production_id.state', 'not in', ['cancel']),
|
||||||
('date_finished', '>=', time_48_hours_ago)
|
('date_finished', '>=', time_48_hours_ago)
|
||||||
], order='id asc')
|
], order='id asc')
|
||||||
# print(finish_orders)
|
# logging.info('完成订单: %s' % finish_orders)
|
||||||
|
|
||||||
# 获取所有未完成订单的ID列表
|
# 获取所有未完成订单的ID列表
|
||||||
order_ids = [order.id for order in not_done_orders]
|
order_ids = [order.id for order in not_done_orders]
|
||||||
@@ -962,14 +970,6 @@ class Sf_Dashboard_Connect(http.Controller):
|
|||||||
material_match = re.search(material_pattern, blank_name)
|
material_match = re.search(material_pattern, blank_name)
|
||||||
material = material_match.group(1) if material_match else 'No match found'
|
material = material_match.group(1) if material_match else 'No match found'
|
||||||
|
|
||||||
state_dict = {
|
|
||||||
'draft': '待排程',
|
|
||||||
'done': '已排程',
|
|
||||||
'processing': '生产中',
|
|
||||||
'finished': '已完成',
|
|
||||||
'ready': '待加工',
|
|
||||||
'progress': '生产中',
|
|
||||||
}
|
|
||||||
|
|
||||||
line_dict = {
|
line_dict = {
|
||||||
'sequence': not_done_index,
|
'sequence': not_done_index,
|
||||||
@@ -985,8 +985,6 @@ class Sf_Dashboard_Connect(http.Controller):
|
|||||||
not_done_index += 1
|
not_done_index += 1
|
||||||
|
|
||||||
for finish_order in finish_orders:
|
for finish_order in finish_orders:
|
||||||
if not finish_order.actual_end_time:
|
|
||||||
continue
|
|
||||||
blank_name = ''
|
blank_name = ''
|
||||||
try:
|
try:
|
||||||
blank_name = finish_order.production_id.move_raw_ids[0].product_id.name
|
blank_name = finish_order.production_id.move_raw_ids[0].product_id.name
|
||||||
@@ -1002,13 +1000,13 @@ class Sf_Dashboard_Connect(http.Controller):
|
|||||||
|
|
||||||
line_dict = {
|
line_dict = {
|
||||||
'sequence': done_index,
|
'sequence': done_index,
|
||||||
'workorder_name': finish_order.name,
|
'workorder_name': finish_order.production_id.name,
|
||||||
'blank_name': blank_name,
|
'blank_name': blank_name,
|
||||||
'material': material,
|
'material': material,
|
||||||
'dimensions': dimensions,
|
'dimensions': dimensions,
|
||||||
'order_qty': order.qty_produced,
|
'order_qty': finish_order.qty_produced,
|
||||||
'finish_time': finish_order.actual_end_time.strftime(
|
'finish_time': finish_order.date_finished.strftime(
|
||||||
'%Y-%m-%d %H:%M:%S') if finish_order.actual_end_time else ' '
|
'%Y-%m-%d %H:%M:%S') if finish_order.date_finished else ' '
|
||||||
|
|
||||||
}
|
}
|
||||||
done_data.append(line_dict)
|
done_data.append(line_dict)
|
||||||
|
|||||||
@@ -1,11 +1,41 @@
|
|||||||
|
import logging
|
||||||
|
|
||||||
from odoo import api, models
|
from odoo import api, models
|
||||||
|
from odoo.exceptions import ValidationError, UserError
|
||||||
|
|
||||||
|
|
||||||
class StockPicking(models.Model):
|
class StockPicking(models.Model):
|
||||||
_inherit = 'stock.picking'
|
_inherit = 'stock.picking'
|
||||||
|
|
||||||
|
def _compute_check(self):
|
||||||
|
super()._compute_check()
|
||||||
|
for picking in self:
|
||||||
|
picking_to_quality = picking.get_picking_to_quality()
|
||||||
|
if not picking_to_quality:
|
||||||
|
picking.quality_check_todo = False
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
need_quality_line = picking.get_need_quality_line(picking_to_quality)
|
||||||
|
if not need_quality_line or all(not line.get('need_done_check_ids') for line in need_quality_line):
|
||||||
|
picking.quality_check_todo = False
|
||||||
|
|
||||||
|
def check_quality(self):
|
||||||
|
self.ensure_one()
|
||||||
|
# checkable_products = self.mapped('move_line_ids').mapped('product_id')
|
||||||
|
# checks = self.check_ids.filtered(lambda check: check.quality_state == 'none' and (
|
||||||
|
# check.product_id in checkable_products or check.measure_on == 'operation'))
|
||||||
|
checks = self.env['quality.check']
|
||||||
|
picking_to_quality = self._get_picking_to_quality()
|
||||||
|
need_quality_line = self.get_need_quality_line(picking_to_quality)
|
||||||
|
if need_quality_line and any(line.get('need_done_check_ids') for line in need_quality_line):
|
||||||
|
for item in need_quality_line:
|
||||||
|
checks += item.get('need_done_check_ids')
|
||||||
|
if checks:
|
||||||
|
return checks.action_open_quality_check_wizard()
|
||||||
|
return False
|
||||||
|
|
||||||
def button_validate(self):
|
def button_validate(self):
|
||||||
"""
|
"""=
|
||||||
出厂检验报告上传
|
出厂检验报告上传
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -17,43 +47,133 @@ class StockPicking(models.Model):
|
|||||||
if not out_quality_check.is_factory_report_uploaded:
|
if not out_quality_check.is_factory_report_uploaded:
|
||||||
if out_quality_check and self.state == 'assigned':
|
if out_quality_check and self.state == 'assigned':
|
||||||
out_quality_check.upload_factory_report()
|
out_quality_check.upload_factory_report()
|
||||||
|
quality_action = self.pinking_checkout_quality()
|
||||||
|
if quality_action:
|
||||||
|
return quality_action
|
||||||
|
res = super(StockPicking, self).button_validate()
|
||||||
|
return res
|
||||||
|
|
||||||
|
def pinking_checkout_quality(self):
|
||||||
"""
|
"""
|
||||||
调拨单若关联了质量检查单,验证调拨单时,应校验是否有不合格品,若存在,应弹窗提示:
|
调拨单若关联了质量检查单,验证调拨单时,应校验是否有不合格品,若存在,应弹窗提示:
|
||||||
“警告:存在不合格产品XXXX n 件、YYYYY m件,继续调拨请点“确认”,否则请取消?”
|
“警告:存在不合格产品XXXX n 件、YYYYY m件,继续调拨请点“确认”,否则请取消?”
|
||||||
"""
|
"""
|
||||||
context = self.env.context
|
try:
|
||||||
if not context.get('again_validate') and self.quality_check_ids.filtered(lambda qc: qc.quality_state == 'fail'):
|
self.ensure_one()
|
||||||
# 回滚事务,为二次确认/取消做准备
|
context = self.env.context
|
||||||
self.env.cr.rollback()
|
if not context.get('pinking_checkout_quality'):
|
||||||
quality_check_ids = self.quality_check_ids.filtered(lambda qc: qc.quality_state == 'fail')
|
picking_to_quality = self._get_picking_to_quality()
|
||||||
product_list = list(set([quality_check_id.product_id for quality_check_id in quality_check_ids]))
|
if not picking_to_quality: return False
|
||||||
fail_check_text = ''
|
need_quality_val = self.get_need_quality_line(picking_to_quality)
|
||||||
for product_id in product_list:
|
if any(line.get('fail_check_ids') for line in need_quality_val):
|
||||||
check_ids = quality_check_ids.filtered(lambda qc: qc.product_id == product_id)
|
# 回滚事务,为二次确认/取消做准备
|
||||||
if all(check_id.measure_on == 'move_line' for check_id in check_ids):
|
self.env.cr.rollback()
|
||||||
number = sum(check_ids.mapped('qty_line'))
|
# 获取存在失败的 质检单 调拨单明细行
|
||||||
else:
|
check_list = [item for item in need_quality_val if item.get('fail_check_ids')]
|
||||||
number = sum(self.move_ids_without_package.filtered(
|
fail_check_text = ''
|
||||||
lambda ml: ml.product_id == product_id).mapped('quantity_done'))
|
for item in check_list:
|
||||||
if number == 0:
|
move_id, pre_done_qty = item.get('move_id'), item.get('pre_done_qty')
|
||||||
number = sum(self.move_ids_without_package.filtered(
|
fail_check_text = (f'{fail_check_text}、{move_id.product_id.display_name} {pre_done_qty}件'
|
||||||
lambda ml: ml.product_id == product_id).mapped('reserved_availability'))
|
if fail_check_text != '' else f'{move_id.product_id.display_name} {pre_done_qty}件')
|
||||||
if number == 0:
|
return {
|
||||||
number = sum(self.move_ids_without_package.filtered(
|
'type': 'ir.actions.act_window',
|
||||||
lambda ml: ml.product_id == product_id).mapped('product_uom_qty'))
|
'res_model': 'picking.validate.check.wizard',
|
||||||
fail_check_text = (f'{fail_check_text}、{product_id.display_name} {number}件'
|
'name': '质检不合格提示',
|
||||||
if fail_check_text != '' else f'{product_id.display_name} {number}件')
|
'view_mode': 'form',
|
||||||
return {
|
'target': 'new',
|
||||||
'type': 'ir.actions.act_window',
|
'context': {
|
||||||
'res_model': 'picking.validate.check.wizard',
|
'default_picking_id': self.id,
|
||||||
'name': '质检不合格提示',
|
'default_fail_check_text': f'警告:存在不合格产品{fail_check_text},继续调拨请点“确认”,否则请取消?',
|
||||||
'view_mode': 'form',
|
'pinking_checkout_quality': True}
|
||||||
'target': 'new',
|
}
|
||||||
'context': {
|
else:
|
||||||
'default_picking_id': self.id,
|
return False
|
||||||
'default_fail_check_text': f'警告:存在不合格产品{fail_check_text},继续调拨请点“确认”,否则请取消?',
|
except Exception as e:
|
||||||
'again_validate': True}
|
logging.info('pinking_checkout_quality()方法报错:%s' % e)
|
||||||
}
|
raise ValidationError('调拨单验证质检单是否合格时报错,请联系管理员处理!!')
|
||||||
res = super(StockPicking, self).button_validate()
|
|
||||||
|
def get_need_quality_line(self, picking_to_quality):
|
||||||
|
"""
|
||||||
|
# 对需要进行质检,还没有质检完成的明细行进行统计
|
||||||
|
# 1、当【质量标准_控制方式】=“产品、作业”,仅校验“预完成数量”>0的产品行对应的质检单必须处理。
|
||||||
|
2、当【质量标准_控制方式】=“数量”时,仅校验“预完成数量”>0的产品行对应的质检单必须处理:
|
||||||
|
1)每一类的“总单数”=【调拨单_需求】时,则已处理的质检单“单数”≥“预完成数量”时,可执行调拨单验证;
|
||||||
|
2)每一类的“总单数”<【调拨单_需求】时,则已处理的质检单“单数”≥0时,可执行调拨单验证;
|
||||||
|
"""
|
||||||
|
res = []
|
||||||
|
for item in picking_to_quality:
|
||||||
|
need_done_check_ids = self.env['quality.check']
|
||||||
|
fail_check_ids = self.env['quality.check']
|
||||||
|
move_id, pre_done_qty, check_ids = item.values()
|
||||||
|
check_ids_1 = check_ids.filtered(lambda qc: qc.measure_on in ('operation', 'product'))
|
||||||
|
if check_ids_1:
|
||||||
|
check_ids_1_done = check_ids_1.filtered(lambda qc: qc.quality_state in ('pass', 'fail'))
|
||||||
|
check_ids_1_fail = check_ids_1.filtered(lambda qc: qc.quality_state == 'fail')
|
||||||
|
check_ids_1_none = check_ids_1.filtered(lambda qc: qc.quality_state == 'none')
|
||||||
|
if check_ids_1 and not check_ids_1_done:
|
||||||
|
need_done_check_ids += check_ids_1_none
|
||||||
|
if check_ids_1_fail:
|
||||||
|
fail_check_ids += check_ids_1_fail
|
||||||
|
|
||||||
|
check_ids_2 = check_ids.filtered(lambda qc: qc.measure_on == 'move_line')
|
||||||
|
if check_ids_2:
|
||||||
|
check_ids_2_done = check_ids_2.filtered(lambda qc: qc.quality_state in ('pass', 'fail'))
|
||||||
|
check_ids_2_fail = check_ids_2.filtered(lambda qc: qc.quality_state == 'fail')
|
||||||
|
check_ids_2_none = check_ids_2.filtered(lambda qc: qc.quality_state == 'none')
|
||||||
|
# 每一类的“总单数”=【调拨单_需求】时,则已处理的质检单“单数”≥“预完成数量”时,可执行调拨单验证;
|
||||||
|
if len(check_ids_2) >= move_id.product_uom_qty and len(check_ids_2_done) < pre_done_qty:
|
||||||
|
need_done_check_ids += check_ids_2_none
|
||||||
|
# 每一类的“总单数”<【调拨单_需求】时,则已处理的质检单“单数”≥0时,可执行调拨单验证
|
||||||
|
elif len(check_ids_2) < move_id.product_uom_qty and len(check_ids_2_done) == 0:
|
||||||
|
need_done_check_ids += check_ids_2_none
|
||||||
|
if check_ids_2_fail:
|
||||||
|
fail_check_ids += check_ids_2_fail
|
||||||
|
|
||||||
|
if need_done_check_ids or fail_check_ids:
|
||||||
|
res.append({'move_id': move_id,
|
||||||
|
'pre_done_qty': pre_done_qty,
|
||||||
|
'check_ids': check_ids,
|
||||||
|
'fail_check_ids': fail_check_ids,
|
||||||
|
'need_done_check_ids': need_done_check_ids})
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
def get_picking_to_quality(self):
|
||||||
|
self.ensure_one()
|
||||||
|
return self._get_picking_to_quality()
|
||||||
|
|
||||||
|
def _get_picking_to_quality(self):
|
||||||
|
"""
|
||||||
|
对需要质检的明细行进行统计(针对“预完成数量”>0的行)
|
||||||
|
"""
|
||||||
|
quality_piking_line_list = []
|
||||||
|
pre_done_qty_lines = self._get_pinking_pre_done_qty()
|
||||||
|
for line in pre_done_qty_lines:
|
||||||
|
move_id, pre_done_qty = line.values()
|
||||||
|
if pre_done_qty == 0:
|
||||||
|
continue
|
||||||
|
product_id = move_id.product_id
|
||||||
|
check_ids = self.check_ids.filtered(lambda c: c.product_id == product_id)
|
||||||
|
quality_piking_line_list.append({'move_id': move_id, 'pre_done_qty': pre_done_qty, 'check_ids': check_ids})
|
||||||
|
return quality_piking_line_list
|
||||||
|
|
||||||
|
def _get_pinking_pre_done_qty(self):
|
||||||
|
"""
|
||||||
|
return: 明细行 及 预完成数量
|
||||||
|
1、若调拨单所有明细行的【完成】=0,且任意行的【预留】<【需求】,则验证时将会话是否需创建欠单。
|
||||||
|
---->此时“预完成数量”=【预留】
|
||||||
|
2、若调拨单任意行的0<【完成】<【需求】,且则验证时将会话是否需创建欠单
|
||||||
|
---->此时“预完成数量”=【完成】
|
||||||
|
"""
|
||||||
|
# if all(move_id.quantity_done == 0 for move_id in self.move_ids_without_package):
|
||||||
|
# pre_done_qty = [{'move_id': move_id, 'pre_done_qty': move_id.reserved_availability} for move_id in
|
||||||
|
# self.move_ids_without_package]
|
||||||
|
# else:
|
||||||
|
# pre_done_qty = [{'move_id': move_id, 'pre_done_qty': move_id.quantity_done} for move_id in
|
||||||
|
# self.move_ids_without_package]
|
||||||
|
pre_done_qty = []
|
||||||
|
for move_id in self.move_ids_without_package:
|
||||||
|
if move_id.quantity_done > 0:
|
||||||
|
pre_done_qty.append({'move_id': move_id, 'pre_done_qty': move_id.quantity_done})
|
||||||
|
else:
|
||||||
|
pre_done_qty.append({'move_id': move_id, 'pre_done_qty': move_id.reserved_availability})
|
||||||
|
return pre_done_qty
|
||||||
|
|||||||
Reference in New Issue
Block a user