自加工坯料制造订单的调拨单零件图号零件名称赋值

This commit is contained in:
liaodanlong
2025-03-20 10:24:34 +08:00
parent 221e25f581
commit cf060d0d6c

View File

@@ -754,7 +754,7 @@ class ReStockMove(models.Model):
if move.product_id.categ_id.type == '成品':
move.part_number = move.product_id.part_number
move.part_name = move.product_id.part_name
elif move.product_id.categ_id.type == '坯料' or move.product_id.categ_id.type == '原材料':
elif move.product_id.categ_id.type == '坯料':
product_name = ''
match = re.search(r'(S\d{5}-\d)', move.product_id.name)
# 如果匹配成功,提取结果
@@ -773,6 +773,34 @@ class ReStockMove(models.Model):
lambda production: re.search(f'{product_name}$', production.product_id.name)
)
if filtered_order_line:
move.part_number = filtered_order_line.part_number
move.part_name = filtered_order_line.part_name
elif move.product_id.categ_id.type == '原材料':
production_id = move.production_id or move.raw_material_production_id
if not production_id:
if not move.origin:
continue
production_id = self.env['mrp.production'].sudo().search(
[('name', '=', move.origin)],limit=1)
product_name = ''
match = re.search(r'(S\d{5}-\d)', production_id.product_id.name)
# 如果匹配成功,提取结果
if match:
product_name = match.group(0)
if move.picking_id.sale_order_id:
sale_order = move.picking_id.sale_order_id
else:
sale_order_name = ''
match = re.search(r'(S\d+)', production_id.product_id.name)
if match:
sale_order_name = match.group(0)
sale_order = self.env['sale.order'].sudo().search(
[('name', '=', sale_order_name)])
filtered_order_line = sale_order.order_line.filtered(
lambda production: re.search(f'{product_name}$', production.product_id.name)
)
if filtered_order_line:
move.part_number = filtered_order_line.part_number
move.part_name = filtered_order_line.part_name