diff --git a/CHANGELOG b/CHANGELOG index c52e64c0d5..a2bc180d37 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Add Dict widget for tree view * Add handle to reordable line of tree views Version 5.2.0 - 2019-05-06 diff --git a/tryton/gui/window/view_form/view/list.py b/tryton/gui/window/view_form/view/list.py index bbfef9a7e3..9431748e99 100644 --- a/tryton/gui/window/view_form/view/list.py +++ b/tryton/gui/window/view_form/view/list.py @@ -21,7 +21,7 @@ from . import View, XMLViewParser from .list_gtk.editabletree import EditableTreeView, TreeView from .list_gtk.widget import (Affix, Char, Text, Int, Boolean, URL, Date, Time, Float, TimeDelta, Binary, M2O, O2O, O2M, M2M, Selection, Reference, - ProgressBar, Button, Image) + Dict, ProgressBar, Button, Image) _ = gettext.gettext @@ -258,6 +258,7 @@ class TreeXMLViewParser(XMLViewParser): 'callto': URL, 'char': Char, 'date': Date, + 'dict': Dict, 'email': URL, 'float': Float, 'image': Image, diff --git a/tryton/gui/window/view_form/view/list_gtk/widget.py b/tryton/gui/window/view_form/view/list_gtk/widget.py index cba9b749fe..68a3e2c5cf 100644 --- a/tryton/gui/window/view_form/view/list_gtk/widget.py +++ b/tryton/gui/window/view_form/view/list_gtk/widget.py @@ -1053,6 +1053,21 @@ class _ReferenceSelection(Selection): return False +class Dict(GenericText): + align = 0.5 + + def __init__(self, view, attrs): + super().__init__(view, attrs) + self.renderer.props.editable = False + + def setter(self, column, cell, store, iter_, user_data=None): + super().setter(column, cell, store, iter_, user_data=None) + cell.props.editable = False + + def get_textual_value(self, record): + return '(%s)' % len(record[self.attrs['name']].get_client(record)) + + class ProgressBar(Cell): align = 0.5 orientations = {