客供料合并

This commit is contained in:
liaodanlong
2025-01-16 11:35:37 +08:00
parent 303fcd0430
commit 5c780c7b82

View File

@@ -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',