From 3543531f61d14d1717df000729890a9ea677e398 Mon Sep 17 00:00:00 2001 From: liaodanlong Date: Thu, 13 Mar 2025 14:13:28 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A8=E9=9D=A2=E5=B7=A5=E8=89=BA=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=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?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/purchase_order.py | 13 +++++++++++++ sf_sale/models/sale_order.py | 2 ++ 2 files changed, 15 insertions(+) diff --git a/sf_manufacturing/models/purchase_order.py b/sf_manufacturing/models/purchase_order.py index 398db85b..de802d66 100644 --- a/sf_manufacturing/models/purchase_order.py +++ b/sf_manufacturing/models/purchase_order.py @@ -117,6 +117,8 @@ class PurchaseOrderLine(models.Model): @api.depends('product_id') def _compute_related_product(self): for record in self: + if record.part_number or record.part_name: + continue if record.product_id.categ_id.name == '坯料': product_name = '' match = re.search(r'(S\d{5}-\d)', record.product_id.name) @@ -135,6 +137,17 @@ class PurchaseOrderLine(models.Model): ) 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 + elif record.product_id.categ_id.name == '表面工艺': + domain = [('name', '=', self.production_id.name), + ('purchase_type', '=', 'consignment')] + purchase_orders = self.env['purchase.order'].search(domain) + purchase_orders_id = self.env['purchase.order'] + for po in purchase_orders: + for line in po.order_line: + if line.product_id.server_product_process_parameters_id == self.surface_technics_parameters_id: + if line.product_qty == 1: + purchase_orders_id = line.order_id + return purchase_orders_id else: record.part_number = record.product_id.part_number record.part_name = record.product_id.part_name diff --git a/sf_sale/models/sale_order.py b/sf_sale/models/sale_order.py index b719ffd1..2b0380c4 100644 --- a/sf_sale/models/sale_order.py +++ b/sf_sale/models/sale_order.py @@ -374,6 +374,8 @@ class RePurchaseOrder(models.Model): 'product_qty': 1, 'product_uom': server_template.uom_id.id, 'related_product': production.product_id.id, + 'part_number': pp.part_number, + 'part_name': pp.part_name, })) # 获取服务商品最后一个供应商的采购员 purchase_user_id = server_template.seller_ids[-1].partner_id.purchase_user_id