changeset 1d3e1d8f7676 in modules/product:default
details: https://hg.tryton.org/modules/product?cmd=changeset;node=1d3e1d8f7676
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
diffstat:
product.py | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diffs (19 lines):
diff -r e36d0b9c10ef -r 1d3e1d8f7676 product.py
--- a/product.py Thu Jul 09 10:21:06 2020 +0100
+++ b/product.py Fri Jul 24 10:03:09 2020 +0200
@@ -218,6 +218,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'