From 64eb66c334674dc93bedcb8859175ec7cd211a42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=B0=A7?= Date: Tue, 31 Dec 2024 11:39:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=80=80=E5=9B=9E=E5=B7=A5?= =?UTF-8?q?=E8=89=BA=E8=AE=BE=E8=AE=A1=E5=90=8E=E5=86=8D=E7=A1=AE=E8=AE=A4?= =?UTF-8?q?=EF=BC=8C=E9=87=87=E8=B4=AD=E5=8D=95=E7=BC=96=E7=A8=8B=E8=8D=89?= =?UTF-8?q?=E7=A8=BF=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_production.py | 25 ++++++++++--------- .../wizard/production_technology_wizard.py | 5 +++- sf_sale/models/sale_order.py | 1 - 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index c63a00b0..b9b3dbbb 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -783,7 +783,7 @@ class MrpProduction(models.Model): workorder.duration_expected = workorder._get_duration_expected() # 外协出入库单处理 - def get_subcontract_pick_purchase(self): + def get_subcontract_pick_purchase(self, special_design_workorder): production_all = self.sorted(lambda x: x.id) product_id_to_production_names = {} grouped_product_ids = {k: list(g) for k, g in @@ -792,18 +792,19 @@ class MrpProduction(models.Model): product_id_to_production_names[product_id] = [p.name for p in pd] sorted_workorders = None for production in production_all: - proc_workorders = [] - process_parameter_workorder = self.env['mrp.workorder'].search( - [('surface_technics_parameters_id', '!=', False), ('production_id', '=', production.id), - ('is_subcontract', '=', True), ('state', '!=', 'cancel')], order='sequence asc') - if process_parameter_workorder: - # 将这些特殊表面工艺工单的采购单与调拨单置为失效 - for workorder in process_parameter_workorder: - workorder._get_surface_technics_purchase_ids().write({'state': 'cancel'}) - workorder.move_subcontract_workorder_ids.write({'state': 'cancel'}) - workorder.move_subcontract_workorder_ids.picking_id.write({'state': 'cancel'}) + # proc_workorders = [] + # process_parameter_workorder = self.env['mrp.workorder'].search( + # [('surface_technics_parameters_id', '!=', False), ('production_id', '=', production.id), + # ('is_subcontract', '=', True), ('state', '!=', 'cancel')], order='sequence asc') + # need_delete_workorder = process_parameter_workorder - special_design_workorder + # for workorder in need_delete_workorder: + # workorder._get_surface_technics_purchase_ids().write({'active': False}) + # workorder.move_subcontract_workorder_ids.write({'state': 'cancel'}) + # workorder.move_subcontract_workorder_ids.picking_id.write({'active': False}) + + if special_design_workorder: consecutive_workorders = [] - sorted_workorders = sorted(process_parameter_workorder, key=lambda w: w.sequence) + sorted_workorders = sorted(special_design_workorder, key=lambda w: w.sequence) # for i, workorder in enumerate(sorted_workorders): # # 检查当前工作订单和下一个工作订单是否连续,并且供应商相同 # if i == 0: diff --git a/sf_manufacturing/wizard/production_technology_wizard.py b/sf_manufacturing/wizard/production_technology_wizard.py index e16e853c..65e87774 100644 --- a/sf_manufacturing/wizard/production_technology_wizard.py +++ b/sf_manufacturing/wizard/production_technology_wizard.py @@ -57,6 +57,7 @@ class ProductionTechnologyWizard(models.TransientModel): # td_upd = self.env['sf.technology.design'].sudo().search(domain) # if td_upd: # ro.write({'sequence': td_upd.sequence, 'active': td_upd.active}) + # 特殊表面工艺 special_design = self.env['sf.technology.design'].sudo().search( [('routing_tag', '=', 'special'), ('production_id', '=', production.id), ('is_auto', '=', False), ('active', 'in', [True, False])]) @@ -112,7 +113,9 @@ class ProductionTechnologyWizard(models.TransientModel): workorder.blocked_by_workorder_ids = blocked_by_workorder_ids[0] productions._create_workorder(False) if self.production_id.product_id.categ_id.type == '成品': - productions.get_subcontract_pick_purchase() + special_design_workorder = self.env['mrp.workorder'].search( + [('technology_design_id', 'in', special_design.ids), ('production_id', '=', special.production_id.id), ('state', '!=', 'cancel')]) + productions.get_subcontract_pick_purchase(special_design_workorder) productions.is_adjust = False for item in productions: workorder = item.workorder_ids.filtered(lambda wo: wo.state not in ('cancel')).sorted( diff --git a/sf_sale/models/sale_order.py b/sf_sale/models/sale_order.py index c9c06b9b..5267725a 100644 --- a/sf_sale/models/sale_order.py +++ b/sf_sale/models/sale_order.py @@ -363,7 +363,6 @@ class RePurchaseOrder(models.Model): server_product_process = [] purchase_order = pp._get_surface_technics_purchase_ids() if purchase_order: - purchase_order.write({'state': 'draft'}) pp.purchase_id = [(6, 0, [purchase_order.id])] else: server_template = self.env['product.template'].search(