From 3b2ced13cf98cb5f73f054d7b6efa7f6b8210232 Mon Sep 17 00:00:00 2001 From: Bastien PIERRE Date: Fri, 8 Dec 2023 14:56:22 +0100 Subject: [PATCH] [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 --- addons/product/models/product_supplierinfo.py | 4 +--- addons/product/views/product_supplierinfo_views.xml | 3 ++- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/addons/product/models/product_supplierinfo.py b/addons/product/models/product_supplierinfo.py index db1b7a05311..b51dd15cbdf 100644 --- a/addons/product/models/product_supplierinfo.py +++ b/addons/product/models/product_supplierinfo.py @@ -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( diff --git a/addons/product/views/product_supplierinfo_views.xml b/addons/product/views/product_supplierinfo_views.xml index 00cdc08f601..da495c47625 100644 --- a/addons/product/views/product_supplierinfo_views.xml +++ b/addons/product/views/product_supplierinfo_views.xml @@ -106,7 +106,8 @@ + 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)]"/>