Accept Merge Request #1753: (feature/customer_supply -> develop)

Merge Request: 客供料与非客供料分开合并

Created By: @廖丹龙
Reviewed By: @胡尧
Approved By: @胡尧 
Accepted By: @廖丹龙
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/1753
This commit is contained in:
廖丹龙
2025-01-14 14:17:26 +08:00
committed by Coding

View File

@@ -1526,8 +1526,7 @@ class MrpProduction(models.Model):
重载创建制造订单的方法,单个制造订单,同一成品只创建一个采购组,用于后续单据的创建 重载创建制造订单的方法,单个制造订单,同一成品只创建一个采购组,用于后续单据的创建
""" """
product_group_id = {} product_group_id = {}
group_id = False is_custemer_group_id = {} # 客供料与非客供料
is_first = False
for vals in vals_list: for vals in vals_list:
if not vals.get('name', False) or vals['name'] == _('New'): if not vals.get('name', False) or vals['name'] == _('New'):
picking_type_id = vals.get('picking_type_id') picking_type_id = vals.get('picking_type_id')
@@ -1537,15 +1536,16 @@ class MrpProduction(models.Model):
vals['name'] = self.env['stock.picking.type'].browse(picking_type_id).sequence_id.next_by_id() vals['name'] = self.env['stock.picking.type'].browse(picking_type_id).sequence_id.next_by_id()
product_id = self.env['product.product'].browse(vals['product_id']) 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_self_process = product_id.materials_type_id and product_id.materials_type_id.gain_way and product_id.materials_type_id.gain_way != '自加工'
if not is_first and is_self_process: is_customer_provided = product_id.is_customer_provided
is_first = True if not is_custemer_group_id.get(is_customer_provided):
group_id = self.env["procurement.group"].create({'name': vals.get('name')}).id is_custemer_group_id[is_customer_provided] = 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 not vals.get('procurement_group_id'):
if product_id.product_tmpl_id.single_manufacturing: if product_id.product_tmpl_id.single_manufacturing:
if product_id.categ_id.name == '成品' and is_self_process: if product_id.categ_id.name == '成品' and is_self_process:
vals['procurement_group_id'] = is_custemer_group_id[is_customer_provided]
vals['procurement_group_id'] = group_id
continue continue
if product_id.id not in product_group_id.keys(): if product_id.id not in product_group_id.keys():
procurement_group_vals = self._prepare_procurement_group_vals(vals) procurement_group_vals = self._prepare_procurement_group_vals(vals)
@@ -1555,7 +1555,7 @@ class MrpProduction(models.Model):
else: else:
vals['procurement_group_id'] = product_group_id[product_id.id] vals['procurement_group_id'] = product_group_id[product_id.id]
else: else:
vals['procurement_group_id'] = group_id vals['procurement_group_id'] = is_custemer_group_id[is_customer_provided]
return super(MrpProduction, self).create(vals_list) return super(MrpProduction, self).create(vals_list)
@api.depends('procurement_group_id.stock_move_ids.created_purchase_line_id.order_id', @api.depends('procurement_group_id.stock_move_ids.created_purchase_line_id.order_id',