From fcd11b3ef00b02c73a127fc2e569f9d5572cc642 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20=C3=89vrard?= Date: Fri, 19 Jun 2020 11:38:10 +0200 Subject: [PATCH] Synchronize cell and editable content in treeview issue9227 review289791002 --- tryton/gui/window/view_form/view/list.py | 1 + tryton/gui/window/view_form/view/list_gtk/widget.py | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/tryton/gui/window/view_form/view/list.py b/tryton/gui/window/view_form/view/list.py index 2c9380825c..137b1e0125 100644 --- a/tryton/gui/window/view_form/view/list.py +++ b/tryton/gui/window/view_form/view/list.py @@ -1044,6 +1044,7 @@ class ViewTree(View): if not name: continue widget = self.get_column_widget(column) + widget.set_editable(current_record) if decoder.decode(widget.attrs.get('tree_invisible', '0')): column.set_visible(False) elif name == self.screen.exclude_field: 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 878144aa9e..1db0a5ffb0 100644 --- a/tryton/gui/window/view_form/view/list_gtk/widget.py +++ b/tryton/gui/window/view_form/view/list_gtk/widget.py @@ -291,6 +291,11 @@ class GenericText(Cell): if callback: callback() + def set_editable(self, record): + if not record or not self.editable: + return + self.editable.set_text(self.get_textual_value(record)) + def editing_started(self, cell, editable, path): def remove(editable): self.editable = None @@ -973,6 +978,14 @@ class Selection(GenericText, SelectionMixin, PopdownMixin): if callback: callback() + def set_editable(self, record): + if not record or not self.editable: + return + field = record[self.attrs['name']] + value = self.get_value(record, field) + self.update_selection(record, field) + self.set_popdown_value(self.editable, value) + def editing_started(self, cell, editable, path): super(Selection, self).editing_started(cell, editable, path) record, field = self._get_record_field_from_path(path)