From f77a1f61670b17aa6e7c8a7d1a1c69fd801595ae Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Sun, 28 Jul 2024 16:05:09 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E4=BC=98=E5=8C=96=E5=B7=A5=E5=8D=95?= =?UTF-8?q?=E7=8A=B6=E6=80=81=EF=BC=9B2=E3=80=81=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7=E4=BD=8D=E7=BD=AE=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E8=87=AA=E5=8A=A8=E8=AE=A1=E7=AE=97=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E8=A7=A6=E5=8F=91=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_workorder.py | 34 ++++++++++++++++---- sf_tool_management/models/functional_tool.py | 3 +- sf_tool_management/models/mrp_workorder.py | 6 ++-- 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index ded46f93..fc037caf 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -848,18 +848,40 @@ class ResMrpWorkOrder(models.Model): # else: # if workorder.state not in ['cancel', 'rework']: # workorder.state = 'rework' - # 当工单对应制造订单的功能刀具状态为 【无效刀】时,先对的第一个装夹预调工单状态设置为 【等待组件】 - if workorder.production_id.tool_state in ['1', '2']: - if workorder.routing_type == '装夹预调': + if workorder.routing_type == '装夹预调' and workorder.state in ['waiting', 'ready', 'pending']: + # 当工单对应制造订单的功能刀具状态为 【无效刀】时,先对的第一个装夹预调工单状态设置为 【等待组件】 + if workorder.production_id.tool_state in ['1', '2']: if workorder.state in ['ready']: workorder.state = 'waiting' continue - elif workorder.state == 'pending' and self.search( + elif workorder.state in ['waiting']: + continue + elif workorder.state == 'pending' and workorder == self.search( [('production_id', '=', workorder.production_id.id), - ('sequence', '=', workorder.sequence - 1), - ('state', 'in', ['done', 'rework'])]): + ('routing_type', '=', '装夹预调'), + ('state', 'not in', ['rework', 'done', 'cancel'])], + limit=1, + order="sequence"): workorder.state = 'waiting' continue + elif workorder.production_id.tool_state in ['0']: + if workorder.production_id.workorder_ids.filtered(lambda a: a.state == 'rework'): + if not workorder.production_id.workorder_ids.filtered( + lambda a: (a.routing_type not in ['装夹预调'] and + a.state not in ['pending', 'done', 'rework', 'cancel'])): + # 查询工序最小的非完工、非返工的装夹预调工单 + work_id = self.search( + [('production_id', '=', workorder.production_id.id), + ('routing_type', '=', '装夹预调'), + ('state', 'not in', ['rework', 'done', 'cancel'])], + limit=1, + order="sequence") + if workorder == work_id: + if workorder.production_id.reservation_state == 'assigned': + workorder.state = 'ready' + elif workorder.production_id.reservation_state != 'assigned': + workorder.state = 'waiting' + continue logging.info('工序:%s' % workorder.sequence) logging.info('工单最终状态:%s' % workorder.state) diff --git a/sf_tool_management/models/functional_tool.py b/sf_tool_management/models/functional_tool.py index 1e496985..dd539fc2 100644 --- a/sf_tool_management/models/functional_tool.py +++ b/sf_tool_management/models/functional_tool.py @@ -53,7 +53,8 @@ class FunctionalCuttingToolEntity(models.Model): safe_inventory_id = fields.Many2one('sf.real.time.distribution.of.functional.tools', string='功能刀具安全库存', readonly=True) - @api.depends('barcode_id.quant_ids', 'functional_tool_status', 'current_shelf_location_id') + @api.depends('barcode_id.quant_ids', 'barcode_id.quant_ids.location_id', 'functional_tool_status', + 'current_shelf_location_id') def _compute_current_location_id(self): for record in self: if record.functional_tool_status == '已拆除': diff --git a/sf_tool_management/models/mrp_workorder.py b/sf_tool_management/models/mrp_workorder.py index 6314a90f..965fa03c 100644 --- a/sf_tool_management/models/mrp_workorder.py +++ b/sf_tool_management/models/mrp_workorder.py @@ -106,9 +106,9 @@ class CNCprocessing(models.Model): 'handle_result': '待处理' }) # 修改当前面装夹预调工单的 is_rework 为 True - work_ids = production_id.workorder_ids.filtered( - lambda a: a.routing_type == '装夹预调' and a.processing_panel == key and not a.is_rework) - work_ids.write({'is_rework': True}) + # work_ids = production_id.workorder_ids.filtered( + # lambda a: a.routing_type == '装夹预调' and a.processing_panel == key and not a.is_rework) + # work_ids.write({'is_rework': True}) # 对缺刀信息进行处理 for key in data2: if data2.get(key):