changeset bf46048e8168 in modules/product:5.6
details: https://hg.tryton.org/modules/product?cmd=changeset;node=bf46048e8168
description:
        Do not copy the template code

        When the variant has no code, the template code is the only part of the 
unique
        constraint. In such case copying the template fails because the new 
variant
        will have the same code.

        issue9462
        review306081002
        (grafted from 1d3e1d8f7676b59cf213d3607fcb30776612410c)
diffstat:

 product.py |  9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diffs (19 lines):

diff -r 71e652d3f73d -r bf46048e8168 product.py
--- a/product.py        Mon May 04 12:19:28 2020 +0200
+++ b/product.py        Fri Jul 24 10:03:09 2020 +0200
@@ -207,6 +207,15 @@
         Product.sync_code(products)
 
     @classmethod
+    def copy(cls, templates, default=None):
+        if default is None:
+            default = {}
+        else:
+            default = default.copy()
+        default.setdefault('code', None)
+        return super().copy(templates, default=default)
+
+    @classmethod
     def search_global(cls, text):
         for record, rec_name, icon in super(Template, cls).search_global(text):
             icon = icon or 'tryton-product'

Reply via email to