details: https://code.tryton.org/tryton/commit/494ed7b5a904
branch: 7.4
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 51fa49730cbd -r 494ed7b5a904 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
@@ -1515,6 +1515,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];
@@ -1531,7 +1534,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 51fa49730cbd -r 494ed7b5a904 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
@@ -583,6 +583,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)
@@ -593,7 +594,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')