From 861c56abc9947043be76552e09b3f8fae71eff1e Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Fri, 9 Feb 2024 22:39:30 +0100 Subject: [PATCH] [FIX] base_product_mass_addition : compute uom_category and uom_id in the same way, to remove the errror : 'UserWarning: Field product.product.quick_uom_id in dependency of product.product.quick_uom_category_id should be searchable. This is necessary to determine which records to recompute when uom.uom.category_id is modified. You should either make the field searchable, or simplify the field dependency. ' --- .../models/product_product.py | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/base_product_mass_addition/models/product_product.py b/base_product_mass_addition/models/product_product.py index 0e87b67fb71..d38c412e45e 100644 --- a/base_product_mass_addition/models/product_product.py +++ b/base_product_mass_addition/models/product_product.py @@ -19,12 +19,12 @@ class ProductProduct(models.Model): "for this product or update the existing one.", ) quick_uom_category_id = fields.Many2one( - "uom.category", related="quick_uom_id.category_id" + "uom.category", compute="_compute_quick_uom_info" ) quick_uom_id = fields.Many2one( "uom.uom", domain="[('category_id', '=', quick_uom_category_id)]", - compute="_compute_quick_uom_id", + compute="_compute_quick_uom_info", inverse="_inverse_set_process_qty", ) @@ -85,15 +85,18 @@ def pma_parent(self): def _default_quick_uom_id(self): raise NotImplementedError - def _compute_quick_uom_id(self): + def _compute_quick_uom_info(self): parent = self.pma_parent - if parent: - for rec in self: - quick_line = parent._get_quick_line(rec) - if quick_line: - rec.quick_uom_id = quick_line.product_uom - else: - rec.quick_uom_id = rec._default_quick_uom_id() + if not parent: + return + + for product in self: + quick_line = parent._get_quick_line(product) + if quick_line: + product.quick_uom_id = quick_line.product_uom + else: + product.quick_uom_id = product._default_quick_uom_id() + product.quick_uom_category_id = product.quick_uom_id.category_id def _compute_process_qty(self): if not self.pma_parent: