From f2528a6924374ae9d52c6ca3c3e982a01040aeb8 Mon Sep 17 00:00:00 2001 From: "Lucas Perais (lpe)" Date: Wed, 24 Apr 2019 13:51:16 +0000 Subject: [PATCH] [FIX] product: template creation packaging_ids Create a new product, but don't save it just yet give it a name, Add some packagings Save Before this commit: - the form to create the packaging had a mandatory product_id field which is useless in a x2m context (fixed in v11.5 with a6557a2306859b378c5b2348d396f29879c909c3) - the packages disappeared after save This was because at template creation, all "real" fields that are on its variants must be manually set after the creation, including packaging_ids OPW 1970589 closes odoo/odoo#32925 Signed-off-by: Lucas Perais (lpe) --- addons/product/models/product_template.py | 3 +++ addons/product/views/product_views.xml | 14 +++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/addons/product/models/product_template.py b/addons/product/models/product_template.py index c8a1268cb52..a4972d2721d 100644 --- a/addons/product/models/product_template.py +++ b/addons/product/models/product_template.py @@ -312,6 +312,9 @@ class ProductTemplate(models.Model): related_vals['volume'] = vals['volume'] if vals.get('weight'): related_vals['weight'] = vals['weight'] + # Please do forward port + if vals.get('packaging_ids'): + related_vals['packaging_ids'] = vals['packaging_ids'] if related_vals: template.write(related_vals) return template diff --git a/addons/product/views/product_views.xml b/addons/product/views/product_views.xml index 8866b7fcb8f..2684d71a764 100644 --- a/addons/product/views/product_views.xml +++ b/addons/product/views/product_views.xml @@ -87,7 +87,7 @@ colspan="4" attrs="{'invisible':['|', ('type', 'not in', ['product', 'consu']), ('product_variant_count', '>', 1)]}" groups="product.group_stock_packaging"> - + @@ -505,6 +505,18 @@ + + + product.packaging.form.view2 + product.packaging + primary + + + + + + + Product Packages product.packaging