From bc9fdfff88fc05a5241e1b58e7256e4d810d4b90 Mon Sep 17 00:00:00 2001
From: Simon Lejeune <sle@openerp.com>
Date: Fri, 6 Dec 2019 10:14:40 +0000
Subject: [PATCH] [FIX] product: multi edit barcode field on template

Writing barcode on a template will only write it on the variants if the
variant count is 1. Make the field readonly on the view according to
this condition.

closes odoo/odoo#41489

X-original-commit: a67ad076f4c079f33602f01ed2b8cbf741aeffc5
Signed-off-by: Simon Lejeune (sle) <sle@openerp.com>
---
 addons/product/views/product_template_views.xml | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/addons/product/views/product_template_views.xml b/addons/product/views/product_template_views.xml
index 0d8ebcf0a1bc..15a4f1fb5d70 100644
--- a/addons/product/views/product_template_views.xml
+++ b/addons/product/views/product_template_views.xml
@@ -5,9 +5,11 @@
         <field name="model">product.template</field>
         <field name="arch" type="xml">
             <tree string="Product" multi_edit="1">
+                <field name="product_variant_count" invisible="1"/>
+
                 <field name="sequence" widget="handle" readonly="1"/>
                 <field name="default_code" optional="show"/>
-                <field name="barcode" optional="hide"/>
+                <field name="barcode" optional="hide" attrs="{'readonly': [('product_variant_count', '>', 1)]}"/>
                 <field name="name"/>
                 <field name="company_id" options="{'no_create_edit': True}"
                     groups="base.group_multi_company" optional="hide"/>
-- 
GitLab