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: