changeset 33055a78cd05 in tryton:default
details: https://hg.tryton.org/tryton?cmd=changeset;node=33055a78cd05
description:
Add help for each value to selection and multiselection
issue9649
review320021002
diffstat:
tryton/common/selection.py | 15 +++++++++++++--
tryton/gui/window/view_form/view/__init__.py | 3 ++-
2 files changed, 15 insertions(+), 3 deletions(-)
diffs (67 lines):
diff -r bb3ee4b1c0ab -r 33055a78cd05 tryton/common/selection.py
--- a/tryton/common/selection.py Sun Feb 14 14:03:55 2021 +0100
+++ b/tryton/common/selection.py Sun Feb 14 14:28:55 2021 +0100
@@ -26,6 +26,7 @@
for k in self.attrs.get('selection_change_with') or [])
key = freeze_value(value)
selection = self.attrs.get('selection', [])[:]
+ help_ = self.attrs.get('help_selection', {})
if (not isinstance(selection, (list, tuple))
and key not in self._values2selection):
try:
@@ -42,6 +43,7 @@
if self.attrs.get('sort', True):
selection.sort(key=operator.itemgetter(1))
self.selection = selection[:]
+ self.help = help_
self.inactive_selection = []
def update_selection(self, record, field):
@@ -63,10 +65,13 @@
self._last_domain = (domain, context)
if (domain, context) == self._last_domain:
return
-
+ fields = ['rec_name']
+ help_field = self.attrs.get('help_field')
+ if help_field:
+ fields.append(help_field)
try:
result = RPCExecute('model', self.attrs['relation'],
- 'search_read', domain, 0, None, None, ['rec_name'],
+ 'search_read', domain, 0, None, None, fields,
context=context)
except RPCException:
result = False
@@ -74,12 +79,18 @@
selection = [(x['id'], x['rec_name']) for x in result]
if self.nullable_widget:
selection.append((None, ''))
+ if help_field:
+ help_ = {x['id']: x[help_field] for x in result}
+ else:
+ help_ = {}
self._last_domain = (domain, context)
self._domain_cache[domain_cache_key] = selection
else:
selection = []
+ help_ = {}
self._last_domain = None
self.selection = selection[:]
+ self.help = help_
self.inactive_selection = []
def filter_selection(self, domain, record, field):
diff -r bb3ee4b1c0ab -r 33055a78cd05
tryton/gui/window/view_form/view/__init__.py
--- a/tryton/gui/window/view_form/view/__init__.py Sun Feb 14 14:03:55
2021 +0100
+++ b/tryton/gui/window/view_form/view/__init__.py Sun Feb 14 14:28:55
2021 +0100
@@ -117,7 +117,8 @@
'relation_field', 'views', 'invisible', 'add_remove',
'sort', 'context', 'size', 'filename', 'autocomplete',
'translate', 'create', 'delete', 'selection_change_with',
- 'schema_model', 'required']:
+ 'schema_model', 'required', 'help_selection',
+ 'help_field']:
if name in field:
node_attrs.setdefault(name, field[name])
return node_attrs