[FIX] product: split domain between python and view

How to reprodruce:
1) Go to product.template view form
2) Open Studio
3) Go to tab 'Purchase' tab
4) Edit list/form view of the seller_ids (supplierinfo)

Before this commit, the domain on product_id of supplierinfo was using
'parent' as if already doing the filter on the view. Because of the complex
domain in the string, a traceback was throw when editing supplierinfo view
with studio on the product.template.

After this commit, the domain on the python side is simpler. The domain for
the view has been moved in the view and changed to not be dependent of the
parent view, but of the context.

Bugfix Task-ID: 3615851

closes odoo/odoo#145586

Signed-off-by: Steve Van Essche <svs@odoo.com>
This commit is contained in:
Bastien PIERRE
2023-12-14 11:41:46 +00:00
parent e0fb0fbc26
commit 3b2ced13cf
2 changed files with 3 additions and 4 deletions
@@ -51,9 +51,7 @@ class SupplierInfo(models.Model):
date_end = fields.Date('End Date', help="End date for this vendor price")
product_id = fields.Many2one(
'product.product', 'Product Variant', check_company=True,
domain="[('product_tmpl_id', '=', parent.id)] if context.get('base_model_name') == 'product.template' else"
" [('product_tmpl_id', '=', parent.product_tmpl_id)] if context.get('base_model_name') == 'product.product' else"
" [('product_tmpl_id', '=', product_tmpl_id)] if product_tmpl_id else []",
domain="[('product_tmpl_id', '=', product_tmpl_id)] if product_tmpl_id else []",
default=_default_product_id,
help="If not set, the vendor price will apply to all variants of this product.")
product_tmpl_id = fields.Many2one(
@@ -106,7 +106,8 @@
<field name="product_id" optional="hide"
readonly="1"
column_invisible="context.get('product_template_invisible_variant', False)"
groups="product.group_product_variant"/>
groups="product.group_product_variant"
domain="[('product_tmpl_id', '=', context.get('default_product_tmpl_id'))] if context.get('default_product_tmpl_id') else [('product_tmpl_id', '=', product_tmpl_id)]"/>
<field name="product_tmpl_id" string="Product"
readonly="1"
column_invisible="context.get('visible_product_tmpl_id', True)"/>