details:   https://code.tryton.org/tryton/commit/2931c0e0ae5c
branch:    default
user:      Nicolas Évrard <[email protected]>
date:      Wed Nov 26 16:39:06 2025 +0100
description:
        Use the widget attributes when populating the popup menu
diffstat:

 tryton/tryton/common/popup_menu.py                           |  11 +++++++----
 tryton/tryton/gui/window/view_form/view/form_gtk/many2one.py |   2 +-
 tryton/tryton/gui/window/view_form/view/list.py              |   8 ++++++--
 3 files changed, 14 insertions(+), 7 deletions(-)

diffs (83 lines):

diff -r 78632c9aa00f -r 2931c0e0ae5c tryton/tryton/common/popup_menu.py
--- a/tryton/tryton/common/popup_menu.py        Fri Oct 24 18:16:51 2025 +0200
+++ b/tryton/tryton/common/popup_menu.py        Wed Nov 26 16:39:06 2025 +0100
@@ -17,7 +17,7 @@
 _ = gettext.gettext
 
 
-def populate(menu, model, record, title='', field=None, context=None):
+def populate(menu, model, record, title='', attributes=None, context=None):
     '''
     Fill menu with the actions of model for the record.
     If title is filled, the actions will be put in a submenu.
@@ -30,6 +30,9 @@
     elif record.id < 0:
         return
 
+    if attributes is None:
+        attributes = {}
+
     def load(record):
         if isinstance(record, int):
             screen = Screen(model, context=context)
@@ -83,10 +86,10 @@
     def edit(menuitem):
         with Window(hide_current=True, allow_similar=True):
             Window.create(model,
-                view_ids=field.attrs.get('view_ids', '').split(','),
+                view_ids=attributes.get('view_ids', '').split(','),
                 res_id=id_(record),
                 mode=['form'],
-                name=field.attrs.get('string'),
+                name=attributes.get('string'),
                 context=context)
 
     if title:
@@ -102,7 +105,7 @@
 
     if len(action_menu):
         action_menu.append(Gtk.SeparatorMenuItem())
-    if field:
+    if attributes:
         edit_item = Gtk.MenuItem(label=_('Edit...'))
         edit_item.connect('activate', edit)
         action_menu.append(edit_item)
diff -r 78632c9aa00f -r 2931c0e0ae5c 
tryton/tryton/gui/window/view_form/view/form_gtk/many2one.py
--- a/tryton/tryton/gui/window/view_form/view/form_gtk/many2one.py      Fri Oct 
24 18:16:51 2025 +0200
+++ b/tryton/tryton/gui/window/view_form/view/form_gtk/many2one.py      Wed Nov 
26 16:39:06 2025 +0100
@@ -341,7 +341,7 @@
         if self.has_target(value):
             populate(
                 menu, self.get_model(), self.id_from_value(value),
-                '', self.field, self.field.get_context(self.record))
+                '', self.attrs, self.field.get_context(self.record))
         return True
 
     def _set_completion(self):
diff -r 78632c9aa00f -r 2931c0e0ae5c 
tryton/tryton/gui/window/view_form/view/list.py
--- a/tryton/tryton/gui/window/view_form/view/list.py   Fri Oct 24 18:16:51 
2025 +0200
+++ b/tryton/tryton/gui/window/view_form/view/list.py   Wed Nov 26 16:39:06 
2025 +0100
@@ -1049,7 +1049,10 @@
                     parent = parent.parent
                 else:
                     populate(menu, group.model_name, record)
+                current_col = defaultdict(lambda: -1)
                 for col in self.treeview.get_columns():
+                    if col.name:
+                        current_col[col.name] += 1
                     if not col.get_visible() or not col.name:
                         continue
                     field = group.fields[col.name]
@@ -1066,9 +1069,10 @@
                         continue
                     label = field.attrs['string']
                     context = field.get_context(record)
+                    col_widget = self.widgets[col.name][current_col[col.name]]
                     populate(
-                        menu, model, record_id, title=label, field=field,
-                        context=context)
+                        menu, model, record_id, title=label,
+                        attributes=col_widget.attributes, context=context)
 
             if selection.count_selected_rows() == 1:
                 group = self.group

Reply via email to