From db4dd337094dd57fbadae5da567aa72fbdf161f1 Mon Sep 17 00:00:00 2001 From: liaodanlong Date: Mon, 24 Mar 2025 15:54:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=A5=E9=94=99=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/sale_order.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sf_manufacturing/models/sale_order.py b/sf_manufacturing/models/sale_order.py index 5548ec38..225f6fe5 100644 --- a/sf_manufacturing/models/sale_order.py +++ b/sf_manufacturing/models/sale_order.py @@ -1,5 +1,7 @@ import logging import json +import re + from odoo import models, fields, api, _ from odoo.exceptions import UserError @@ -72,8 +74,13 @@ class SaleOrder(models.Model): 'price': product.list_price, 'embryo_redundancy_id': line.embryo_redundancy_id, } + product_name = '' + match = re.search(r'(S\d{5}-\d)', product.name) + # 如果匹配成功,提取结果 + if match: + product_name = match.group(0) # 获取成品名结尾-n的n - product_seria = int(product.name.split('-')[-1]) + product_seria = int(product_name.split('-')[-1]) # 成品供货方式为采购则不生成bom if line.supply_method != 'purchase': bom_data = self.env['mrp.bom'].with_user(self.env.ref("base.user_admin")).get_bom(product)