changeset a2a17a55554e in modules/product:default
details: https://hg.tryton.org/modules/product?cmd=changeset;node=a2a17a55554e
description:
Hide product fields inherited from template when empty
This makes the form less confusing for user when he tries to create a
product
from a Many2One.
issue9020
review284751002
diffstat:
CHANGELOG | 1 +
product.py | 7 +++++++
2 files changed, 8 insertions(+), 0 deletions(-)
diffs (25 lines):
diff -r 9581ad530d49 -r a2a17a55554e CHANGELOG
--- a/CHANGELOG Thu Mar 05 00:25:53 2020 +0100
+++ b/CHANGELOG Thu Mar 05 00:27:49 2020 +0100
@@ -1,3 +1,4 @@
+* Hide product fields inherited from template when empty
* Skip default products when template is created from product
* Search also on variant name when searching on template record name
diff -r 9581ad530d49 -r a2a17a55554e product.py
--- a/product.py Thu Mar 05 00:25:53 2020 +0100
+++ b/product.py Thu Mar 05 00:27:49 2020 +0100
@@ -253,6 +253,13 @@
tfield = copy.deepcopy(tfield)
if hasattr(tfield, 'field'):
tfield.field = None
+ invisible_state = ~Eval('template')
+ if 'invisible' in tfield.states:
+ tfield.states['invisible'] |= invisible_state
+ else:
+ tfield.states['invisible'] = invisible_state
+ if 'template' not in tfield.depends:
+ tfield.depends.append('template')
setattr(cls, attr, TemplateFunction(tfield))
order_method = getattr(cls, 'order_%s' % attr, None)
if (not order_method