details:   https://code.tryton.org/tryton/commit/c82f9d8284c5
branch:    7.0
user:      Cédric Krier <[email protected]>
date:      Thu Dec 18 00:39:38 2025 +0100
description:
        Set toolbar button sensitiveness based on record id instead of position
        (grafted from 2d8bed1160c9595b7ff2eb3f26114e8d6e7ea02f)
diffstat:

 sao/src/tab.js                   |  5 ++++-
 tryton/tryton/gui/window/form.py |  3 ++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diffs (42 lines):

diff -r 5533599e894e -r c82f9d8284c5 sao/src/tab.js
--- a/sao/src/tab.js    Tue Dec 16 11:56:31 2025 +0100
+++ b/sao/src/tab.js    Thu Dec 18 00:39:38 2025 +0100
@@ -1463,6 +1463,9 @@
             const view_type = this.screen.current_view.view_type;
             var next_view_type = this.screen.next_view_type;
             const has_views = this.screen.number_of_views > 1;
+            let sensitive = (
+                record_id >= 0 ? record_id !== null && record_id !== undefined 
:
+                false);
             var buttons = ['print', 'relate', 'email', 'attach'];
             for (const button_id of buttons) {
                 const button = this.buttons[button_id];
@@ -1479,7 +1482,7 @@
                             return keyword == button_id;
                         });
                 }
-                set_sensitive(button_id, position && can_be_sensitive);
+                set_sensitive(button_id, sensitive && can_be_sensitive);
             }
             set_sensitive(
                 'switch_',
diff -r 5533599e894e -r c82f9d8284c5 tryton/tryton/gui/window/form.py
--- a/tryton/tryton/gui/window/form.py  Tue Dec 16 11:56:31 2025 +0100
+++ b/tryton/tryton/gui/window/form.py  Thu Dec 18 00:39:38 2025 +0100
@@ -582,6 +582,7 @@
         has_views = self.screen.number_of_views > 1
         if selected > 1:
             name += '#%i' % selected
+        sensitive = record_id >= 0 if record_id is not None else False
         for button_id in ['print', 'relate', 'email', 'open', 'attach']:
             button = self.buttons[button_id]
             can_be_sensitive = getattr(button, '_can_be_sensitive', True)
@@ -592,7 +593,7 @@
                 can_be_sensitive |= any(
                     b.attrs.get('keyword', 'action') == action_type
                     for b in self.screen.get_buttons())
-            set_sensitive(button_id, bool(position) and can_be_sensitive)
+            set_sensitive(button_id, sensitive and can_be_sensitive)
         set_sensitive(
             'switch',
             (position or view_type == 'form' or next_view_type != 'form')

Reply via email to