Skip to content

Commit

Permalink
[FIX] fix product.template related fields
Browse files Browse the repository at this point in the history
make product.template.product_variant_id a stored computed field to
avoid the following error when setting the print_category_id or to_print
related fields: "non-stored field product.template.product_variant_id
cannot be searched."
  • Loading branch information
huguesdk committed Nov 28, 2023
1 parent 6e3c82c commit a00f0c6
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions product_print_category/models/product_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ class ProductTemplate(models.Model):
_name = "product.template"
_inherit = ["product.template", "product.print.category.mixin"]

# store this field (required for the related fields below)
product_variant_id = fields.Many2one(store=True)

print_category_id = fields.Many2one(
related="product_variant_id.print_category_id", readonly=False
)
Expand Down

0 comments on commit a00f0c6

Please sign in to comment.