From 3f276f4177ea7fde26cf4ef4a7914a93ad62800d Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Fri, 22 Nov 2024 17:57:18 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E4=BC=98=E5=8C=96=E8=BF=94=E5=B7=A5?= =?UTF-8?q?=E6=8C=89=E9=92=AE=EF=BC=9B2=E3=80=81=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=B7=A5=E5=8D=95=E7=8A=B6=E6=80=81=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_production.py | 10 +++++++++- sf_manufacturing/models/mrp_workorder.py | 2 +- sf_manufacturing/wizard/rework_wizard.py | 17 +++-------------- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 118af095..ed792459 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -1126,6 +1126,14 @@ class MrpProduction(models.Model): cloud_programming = None if self.programming_state in ['已编程']: cloud_programming = self._cron_get_programming_state() + result_ids = self.detection_result_ids.filtered(lambda dr: dr.handle_result == '待处理') + work_ids = [] + if result_ids: + for result_id in result_ids: + work_ids.append(self.workorder_ids.filtered( + lambda wk: (wk.name == result_id.routing_type + and wk.processing_panel == result_id.processing_panel + and wk.state == 'done')).id) return { 'name': _('返工'), 'type': 'ir.actions.act_window', @@ -1134,7 +1142,7 @@ class MrpProduction(models.Model): 'target': 'new', 'context': { 'default_production_id': self.id, - 'default_workorder_ids': self.workorder_ids.filtered(lambda wk: wk.state == 'done').ids, + 'default_workorder_ids': work_ids, 'default_reprogramming_num': cloud_programming['reprogramming_num'], 'default_programming_state': cloud_programming['programming_state'], 'default_is_reprogramming': True if cloud_programming['programming_state'] in ['已下发'] else False diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 2fe44d86..a23dbaa1 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -1094,7 +1094,7 @@ class ResMrpWorkOrder(models.Model): # if purchase_order.picking_ids.filtered(lambda p: p.state in ['waiting', 'confirmed', 'assigned']): # workorder.state = 'waiting' # continue - if workorder.routing_type == '表面工艺': + if workorder.technology_design_id.routing_tag == 'special': if workorder.is_subcontract is False: workorder.state = 'ready' else: diff --git a/sf_manufacturing/wizard/rework_wizard.py b/sf_manufacturing/wizard/rework_wizard.py index b2c251f7..5a697f31 100644 --- a/sf_manufacturing/wizard/rework_wizard.py +++ b/sf_manufacturing/wizard/rework_wizard.py @@ -51,18 +51,6 @@ class ReworkWizard(models.TransientModel): self.workorder_id.button_finish() else: if self.workorder_ids: - # handle_result = self.production_id.detection_result_ids.filtered( - # lambda dr: dr.handle_result == '待处理') - # if handle_result: - # processing_panels_to_handle = set(handle_item.processing_panel for handle_item in handle_result) - # processing_panels_choice = set(dr_panel.name for dr_panel in self.processing_panel_id) - # # 使用集合的差集操作找出那些待处理结果中有但实际可用加工面中没有的加工面 - # processing_panels_missing = processing_panels_to_handle - processing_panels_choice - # # 存在不一致的加工面 - # if processing_panels_missing: - # processing_panels_str = ','.join(processing_panels_missing) - # raise UserError('您还有待处理的检测结果中为%s的加工面未选择' % processing_panels_str) - rework_workorder_ids = self.production_id.workorder_ids.filtered( lambda ap: ap.id in self.workorder_ids.ids) clamp_workorder_ids = None @@ -87,8 +75,9 @@ class ReworkWizard(models.TransientModel): (item.route_id.name == work.name and item.panel and item.panel == work.processing_panel)) if route: - workorders_values.append( - self.env['mrp.workorder'].json_workorder_str(self.production_id, route[0])) + work_list = self.env['mrp.workorder'].json_workorder_str(self.production_id, route[0]) + work_list[2].update({'tag_type': '重新加工'}) + workorders_values.append(work_list) # 创建新工单,并进行返工配置的相关操作 if workorders_values: # 创建新工单、工序排序、完成检测结果单据