From b3741b52b24bb08c299670bcbe1547d844ad4e8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 24 Jul 2020 10:03:09 +0200 Subject: [PATCH] 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 --- product.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/product.py b/product.py index dd745a035d..137a454b64 100644 --- a/product.py +++ b/product.py @@ -217,6 +217,15 @@ class Template( products = sum((t.products for t in templates), ()) 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):