From e84842d0a3a046dd54ff5822446a5f83ff39d24a Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Sun, 28 Jul 2024 16:23:17 +0800 Subject: [PATCH 1/4] =?UTF-8?q?1=E3=80=81=E5=8A=9F=E8=83=BD=E5=88=80?= =?UTF-8?q?=E5=85=B7=E7=8A=B6=E6=80=81=E5=A4=87=E6=B3=A8=E5=80=BC=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E8=AE=A1=E7=AE=97=E6=96=B9=E6=B3=95=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_production.py | 7 +++++-- sf_manufacturing/models/mrp_workorder.py | 7 ++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 6eff353d..e6668ecf 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -38,10 +38,13 @@ class MrpProduction(models.Model): if item.workorder_ids: workorder_ids = item.workorder_ids.filtered(lambda a: a.state not in ('rework', '返工')) if workorder_ids.filtered(lambda a: a.tool_state_remark): - work_ids = workorder_ids.filtered(lambda a: a.tool_state_remark) + work_ids = workorder_ids.filtered(lambda a: a.tool_state == '1' and a.state not in ['rework']) tool_state_remark = '' for work_id in work_ids: - tool_state_remark = f"{work_id.tool_state_remark}\n" + if tool_state_remark == '': + tool_state_remark = f"{work_id.tool_state_remark}" + else: + tool_state_remark = f"{tool_state_remark}\n{work_id.tool_state_remark}" item.tool_state_remark = tool_state_remark else: item.tool_state_remark = False diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 76664a35..925fcc8f 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -189,11 +189,12 @@ class ResMrpWorkOrder(models.Model): if item.cnc_ids.filtered(lambda a: a.tool_state == '2'): item.tool_state_remark = None elif item.cnc_ids.filtered(lambda a: a.tool_state == '1'): - tool_state_remark = f'{item.processing_panel}缺刀:[' + tool_state_remark = [] cnc_ids = item.cnc_ids.filtered(lambda a: a.tool_state == '1') for cnc_id in cnc_ids: - tool_state_remark = f"{tool_state_remark}'{cnc_id.cutting_tool_name}'" - item.tool_state_remark = f"{tool_state_remark}]" + if cnc_id.cutting_tool_name not in tool_state_remark: + tool_state_remark.append(cnc_id.cutting_tool_name) + item.tool_state_remark = f"{item.processing_panel}缺刀:{tool_state_remark}]" else: item.tool_state_remark = None From 55016918eb3d2b97e0e3eb6ace95e80bb5c8edef Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Sun, 28 Jul 2024 16:35:17 +0800 Subject: [PATCH 2/4] =?UTF-8?q?1=E3=80=81=E6=B7=BB=E5=8A=A0=E5=B7=A5?= =?UTF-8?q?=E5=8D=95=E7=8A=B6=E6=80=81=E8=87=AA=E5=8A=A8=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E7=9A=84=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 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 925fcc8f..44c019eb 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -821,7 +821,8 @@ class ResMrpWorkOrder(models.Model): }] return workorders_values_str - @api.depends('production_availability', 'blocked_by_workorder_ids', 'blocked_by_workorder_ids.state') + @api.depends('production_availability', 'blocked_by_workorder_ids', 'blocked_by_workorder_ids.state', + 'production_id.tool_state') def _compute_state(self): super()._compute_state() for workorder in self: From 639dd4e78daa670ef498453d2f4b4914eb431f39 Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Mon, 29 Jul 2024 11:32:33 +0800 Subject: [PATCH 3/4] =?UTF-8?q?1=E3=80=81=E5=A4=84=E7=90=86=E5=A4=A7?= =?UTF-8?q?=E6=89=B9=E9=87=8F=E4=BF=AE=E6=94=B9cnc=E7=BC=96=E7=A8=8B?= =?UTF-8?q?=E5=8D=95=E7=9A=84=E5=B7=A5=E5=8D=95=E7=8A=B6=E6=80=81=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E5=AF=BC=E8=87=B4=E5=B7=A5=E5=8D=95=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E7=9A=84=E8=87=AA=E5=8A=A8=E8=AE=A1=E7=AE=97=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E8=BF=9B=E8=A1=8C=E9=80=92=E5=BD=92=E8=80=8C=E4=BA=A7=E7=94=9F?= =?UTF-8?q?=E7=9A=84=E6=A0=88=E6=BA=A2=E5=87=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_production.py | 20 ++++++++++++++------ sf_manufacturing/models/mrp_workorder.py | 2 +- sf_tool_management/models/functional_tool.py | 11 ++++++++++- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index e6668ecf..b99d1b25 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -36,9 +36,11 @@ class MrpProduction(models.Model): def _compute_tool_state_remark(self): for item in self: if item.workorder_ids: - workorder_ids = item.workorder_ids.filtered(lambda a: a.state not in ('rework', '返工')) - if workorder_ids.filtered(lambda a: a.tool_state_remark): - work_ids = workorder_ids.filtered(lambda a: a.tool_state == '1' and a.state not in ['rework']) + work_ids = [] + for workorder_id in item.workorder_ids: + if workorder_id.tool_state == '1': + work_ids.append(workorder_id) + if work_ids: tool_state_remark = '' for work_id in work_ids: if tool_state_remark == '': @@ -54,10 +56,16 @@ class MrpProduction(models.Model): for item in self: if item.workorder_ids: tool_state = item.tool_state - workorder_ids = item.workorder_ids.filtered(lambda a: a.state not in ('rework', '返工')) - if workorder_ids.filtered(lambda a: a.tool_state == '2'): + work_ids_1 = [] + work_ids_2 = [] + for workorder_id in item.workorder_ids: + if workorder_id.tool_state == '2': + work_ids_2.append(workorder_id) + elif workorder_id.tool_state == '1': + work_ids_1.append(workorder_id) + if work_ids_2: item.tool_state = '2' - elif workorder_ids.filtered(lambda a: a.tool_state == '1'): + elif work_ids_1: item.tool_state = '1' else: item.tool_state = '0' diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 44c019eb..65f85048 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -194,7 +194,7 @@ class ResMrpWorkOrder(models.Model): for cnc_id in cnc_ids: if cnc_id.cutting_tool_name not in tool_state_remark: tool_state_remark.append(cnc_id.cutting_tool_name) - item.tool_state_remark = f"{item.processing_panel}缺刀:{tool_state_remark}]" + item.tool_state_remark = f"{item.processing_panel}缺刀:{tool_state_remark}" else: item.tool_state_remark = None diff --git a/sf_tool_management/models/functional_tool.py b/sf_tool_management/models/functional_tool.py index dd539fc2..0d9473ca 100644 --- a/sf_tool_management/models/functional_tool.py +++ b/sf_tool_management/models/functional_tool.py @@ -263,8 +263,17 @@ class FunctionalCuttingToolEntity(models.Model): if self.tool_name_id.name: cnc_processing_ids = self.env['sf.cnc.processing'].search( [('tool_state', '=', '1'), ('cutting_tool_name', '=', self.tool_name_id.name)]) + production_ids = [] if cnc_processing_ids: - cnc_processing_ids.sudo().write({'tool_state': '0'}) + for item in cnc_processing_ids: + if item.workorder_id and item.workorder_id.production_id not in production_ids: + production_ids.append(item.workorder_id.production_id) + if production_ids: + # 对同一制造订单的工单的cnc编程单的功能刀具状态进行变更,并调用工单的功能刀具状态计算方法 + for production_id in production_ids: + cnc_ids = cnc_processing_ids.filtered(lambda a: a.workorder_id.production_id == production_id) + cnc_ids.sudo().write({'tool_state': '0'}) + cnc_ids.workorder_id._compute_tool_state() def tool_inventory_displacement_out(self): """ From fffe0a230ba230a0e49f704b8f8b6f0fb9c69f5c Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Mon, 29 Jul 2024 15:40:44 +0800 Subject: [PATCH 4/4] 1 --- sf_tool_management/wizard/wizard.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sf_tool_management/wizard/wizard.py b/sf_tool_management/wizard/wizard.py index 4edd3617..ea82d5dc 100644 --- a/sf_tool_management/wizard/wizard.py +++ b/sf_tool_management/wizard/wizard.py @@ -876,7 +876,7 @@ class StockPicking(models.Model): if not stock_id: num = "%05d" % 1 else: - m = int(stock_id.name[-3:]) + 1 + m = int(stock_id.name[-5:]) + 1 num = "%05d" % m return name + str(num)