From 23da273af14e03ab5160d04e6514139a2dc4c1b0 Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Wed, 20 Nov 2024 16:08:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug=E5=92=8C=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E5=88=B6=E9=80=A0=E8=AE=A2=E5=8D=95=E6=8A=A5=E5=BA=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_production.py | 35 ++++++------ sf_manufacturing/models/mrp_workorder.py | 19 +++---- .../views/mrp_production_addional_change.xml | 8 ++- .../production_technology_re_adjust_wizard.py | 12 +++-- .../wizard/production_technology_wizard.py | 8 ++- sf_manufacturing/wizard/production_wizard.py | 53 ------------------- 6 files changed, 50 insertions(+), 85 deletions(-) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index e9e4d9ff..0bc01470 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -311,13 +311,10 @@ class MrpProduction(models.Model): # 新添加的状态逻辑 if ( production.state == 'to_close' or production.state == 'progress') and production.schedule_state == '未排': - if not production.workorder_ids: + if not production.workorder_ids or production.is_adjust is True: production.state = 'technology_to_confirmed' else: - if production.is_adjust == True: - production.state = 'technology_to_confirmed' - else: - production.state = 'confirmed' + production.state = 'confirmed' elif production.state == 'pending_cam' and production.schedule_state == '未排': production.state = 'confirmed' elif production.state == 'to_close' and production.schedule_state == '已排': @@ -683,24 +680,28 @@ class MrpProduction(models.Model): if production.product_id.categ_id.type == '成品': # # 根据工序设计生成工单 for route in production.technology_design_ids: - if route.route_id.routing_type not in ['表面工艺']: - workorders_values.append( - self.env['mrp.workorder'].json_workorder_str(production, route)) - else: - product_production_process = self.env['product.template'].search( - [('server_product_process_parameters_id', '=', route.process_parameters_id.id)]) - workorders_values.append( - self.env[ - 'mrp.workorder']._json_workorder_surface_process_str( - production, route, product_production_process.seller_ids[0].partner_id.id)) + workorder_has = self.env['mrp.workorder'].search([('name', '=', route.route_id.name)]) + if not workorder_has: + if route.route_id.routing_type not in ['表面工艺']: + workorders_values.append( + self.env['mrp.workorder'].json_workorder_str(production, route)) + else: + product_production_process = self.env['product.template'].search( + [('server_product_process_parameters_id', '=', route.process_parameters_id.id)]) + workorders_values.append( + self.env[ + 'mrp.workorder']._json_workorder_surface_process_str( + production, route, product_production_process.seller_ids[0].partner_id.id)) elif production.product_id.categ_id.type == '坯料': embryo_routing_workcenter = self.env['sf.embryo.model.type.routing.sort'].search( [('embryo_model_type_id', '=', production.product_id.embryo_model_type_id.id)], order='sequence asc' ) for route_embryo in embryo_routing_workcenter: - workorders_values.append( - self.env['mrp.workorder'].json_workorder_str('', production, route_embryo)) + workorder_embryo_has = self.env['mrp.workorder'].search([('name', '=', route.route_id.name)]) + if not workorder_embryo_has: + workorders_values.append( + self.env['mrp.workorder'].json_workorder_str('', production, route_embryo)) production.workorder_ids = workorders_values for workorder in production.workorder_ids: workorder.duration_expected = workorder._get_duration_expected() diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 78618c55..6b0f0004 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -782,7 +782,7 @@ class ResMrpWorkOrder(models.Model): routing_types = ['切割', '装夹预调', 'CNC加工', '解除装夹'] if route.route_id.routing_type in routing_types: routing_workcenter = self.env['mrp.routing.workcenter'].sudo().search( - [('name', '=', route.route_id.routing_type)]) + [('name', '=', oute.routing_type if hasattr(route, 'routing_type') else route.route_id.routing_type)]) duration_expected = routing_workcenter.time_cycle reserved_duration = routing_workcenter.reserved_duration else: @@ -792,14 +792,15 @@ class ResMrpWorkOrder(models.Model): 'product_uom_id': production.product_uom_id.id, 'qty_producing': 0, 'operation_id': False, - 'name': route.route_id.name, - 'processing_panel': route.panel, - 'sequence': route.sequence, - 'quality_point_ids': route.route_id.quality_point_ids, - 'routing_type': route.route_id.routing_type, - 'workcenter_id': self.env['mrp.routing.workcenter'].get_workcenter(route.route_id.workcenter_ids.ids, - route.route_id.routing_type, - production.product_id), + 'name': route.name if hasattr(route, 'routing_type') else route.route_id.name, + 'processing_panel': False if hasattr(route, 'routing_type') else route.panel, + 'sequence': 1 if hasattr(route, 'routing_type') else route.sequence, + 'quality_point_ids': False if hasattr(route, 'routing_type') else route.route_id.quality_point_ids, + 'routing_type': route.routing_type if hasattr(route, 'routing_type') else route.route_id.routing_type, + 'workcenter_id': False if hasattr(route, 'routing_type') else self.env[ + 'mrp.routing.workcenter'].get_workcenter(route.route_id.workcenter_ids.ids, + route.route_id.routing_type, + production.product_id), # 设定初始化值,避免出现变成bool问题 'date_planned_start': datetime.now(), 'date_planned_finished': datetime.now() + timedelta(days=1), diff --git a/sf_manufacturing/views/mrp_production_addional_change.xml b/sf_manufacturing/views/mrp_production_addional_change.xml index 99b1e4ba..22ffb3b9 100644 --- a/sf_manufacturing/views/mrp_production_addional_change.xml +++ b/sf_manufacturing/views/mrp_production_addional_change.xml @@ -84,6 +84,12 @@ technology_to_confirmed,confirmed,pending_cam,progress,rework,scrap,done + + 1 + + + 1 + @@ -139,7 +145,7 @@ + attrs="{'invisible': [('state', '!=', 'technology_to_confirmed')]}">