From ce0ead4da6a995342e3615b07ed717a6d297b7d6 Mon Sep 17 00:00:00 2001 From: liaodanlong Date: Mon, 12 May 2025 17:13:52 +0800 Subject: [PATCH] =?UTF-8?q?sf-=E5=B7=A5=E5=BA=8F-=E6=89=8B=E5=8A=A8?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E5=B7=A5=E8=89=BA=E5=8F=AF=E9=80=89=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E5=8F=8A=E4=BA=A7=E5=93=81=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/sf_production_common.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/sf_manufacturing/models/sf_production_common.py b/sf_manufacturing/models/sf_production_common.py index 3c4ad8cf..8db07b53 100644 --- a/sf_manufacturing/models/sf_production_common.py +++ b/sf_manufacturing/models/sf_production_common.py @@ -9,7 +9,7 @@ class SfProductionProcessParameter(models.Model): _inherit = 'sf.production.process.parameter' service_products = fields.Many2one( 'product.template', - string='外协服务产品',compute='_compute_service_products',inverse='_inverse_service_products', + string='外协服务产品',compute='_compute_service_products', store=True ) outsourced_service_products = fields.One2many( @@ -25,15 +25,8 @@ class SfProductionProcessParameter(models.Model): def _compute_service_products(self): for record in self: # 假设取第一条作为主明细 - record.service_products = record.outsourced_service_products.ids if record.outsourced_service_products else False + record.service_products = record.outsourced_service_products[0].id if record.outsourced_service_products else False - def _inverse_service_products(self): - for record in self: - if record.service_products: - # 确保关联关系正确 - record.outsourced_service_products = record.service_products.ids if record.service_products else False - else: - record.outsourced_service_products = False def name_get(self): result = [] for record in self: