匹配规则修改

This commit is contained in:
liaodanlong
2025-02-26 11:25:09 +08:00
parent 85c8e834cb
commit 2e47922086
2 changed files with 3 additions and 3 deletions

View File

@@ -124,14 +124,14 @@ class PurchaseOrderLine(models.Model):
if match:
product_name = match.group(0)
sale_order_name = ''
match_sale = re.search(r'(S\d+)', record.product_id.name)
match_sale = re.search(r'(\d+)', record.product_id.name)
if match_sale:
sale_order_name = match_sale.group(0)
sale_order = self.env['sale.order'].sudo().search(
[('name', '=', sale_order_name)])
if sale_order:
filtered_order_line = sale_order.order_line.filtered(
lambda order_line: re.search(f'S{product_name}$', order_line.product_id.name)
lambda order_line: re.search(f'{product_name}$', order_line.product_id.name)
)
record.part_number = filtered_order_line.product_id.part_number if filtered_order_line else None
record.part_name = filtered_order_line.product_id.part_name if filtered_order_line else None