From 5c780c7b828c43e97a4383c9e22d65eda82af834 Mon Sep 17 00:00:00 2001 From: liaodanlong Date: Thu, 16 Jan 2025 11:35:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=A2=E4=BE=9B=E6=96=99=E5=90=88=E5=B9=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_production.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 24d4bdd1..18d0e469 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -1537,15 +1537,16 @@ class MrpProduction(models.Model): product_id = self.env['product.product'].browse(vals['product_id']) is_self_process = product_id.materials_type_id and product_id.materials_type_id.gain_way and product_id.materials_type_id.gain_way != '自加工' is_customer_provided = product_id.is_customer_provided - if not is_custemer_group_id.get(is_customer_provided) and is_self_process: - is_custemer_group_id[is_customer_provided] = self.env["procurement.group"].create({'name': vals.get('name')}).id + key = f"{is_self_process}_{is_customer_provided}" + if not is_custemer_group_id.get(key): + is_custemer_group_id[key] = self.env["procurement.group"].create({'name': vals.get('name')}).id # if not (is_first_customer or is_first_not_customer) and is_self_process: # is_first = True # group_id = self.env["procurement.group"].create({'name': vals.get('name')}).id if not vals.get('procurement_group_id'): if product_id.product_tmpl_id.single_manufacturing: - if product_id.categ_id.name == '成品' and is_self_process: - vals['procurement_group_id'] = is_custemer_group_id[is_customer_provided] + if product_id.categ_id.name == '成品': + vals['procurement_group_id'] = is_custemer_group_id[key] continue if product_id.id not in product_group_id.keys(): procurement_group_vals = self._prepare_procurement_group_vals(vals) @@ -1555,7 +1556,7 @@ class MrpProduction(models.Model): else: vals['procurement_group_id'] = product_group_id[product_id.id] else: - vals['procurement_group_id'] = is_custemer_group_id[is_customer_provided] + vals['procurement_group_id'] = is_custemer_group_id[key] return super(MrpProduction, self).create(vals_list) @api.depends('procurement_group_id.stock_move_ids.created_purchase_line_id.order_id',