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
This commit is contained in:
Cédric Krier
2020-07-24 10:03:09 +02:00
parent 5d5ded1736
commit b3741b52b2
+9
View File
@@ -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):