From cf060d0d6c72f6e6e1ded2a893825f601932bc2a Mon Sep 17 00:00:00 2001 From: liaodanlong Date: Thu, 20 Mar 2025 10:24:34 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=8A=A0=E5=B7=A5=E5=9D=AF=E6=96=99?= =?UTF-8?q?=E5=88=B6=E9=80=A0=E8=AE=A2=E5=8D=95=E7=9A=84=E8=B0=83=E6=8B=A8?= =?UTF-8?q?=E5=8D=95=E9=9B=B6=E4=BB=B6=E5=9B=BE=E5=8F=B7=E9=9B=B6=E4=BB=B6?= =?UTF-8?q?=E5=90=8D=E7=A7=B0=E8=B5=8B=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/stock.py | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/sf_manufacturing/models/stock.py b/sf_manufacturing/models/stock.py index 57fb443f..ffea3b36 100644 --- a/sf_manufacturing/models/stock.py +++ b/sf_manufacturing/models/stock.py @@ -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