Skip to content

Commit

Permalink
[FIX] base_product_mass_addition : compute uom_category and uom_id in…
Browse files Browse the repository at this point in the history
… 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.

'
  • Loading branch information
legalsylvain committed Feb 28, 2024
1 parent f5511b7 commit 861c56a
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions base_product_mass_addition/models/product_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)

Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 861c56a

Please sign in to comment.