details: https://code.tryton.org/tryton/commit/a8858f7983bf
branch: 7.8
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 | 7 +++++--
tryton/tryton/gui/window/form.py | 5 +++--
2 files changed, 8 insertions(+), 4 deletions(-)
diffs (49 lines):
diff -r b7fb8e671bbe -r a8858f7983bf sao/src/tab.js
--- a/sao/src/tab.js Tue Dec 16 17:15:40 2025 +0100
+++ b/sao/src/tab.js Thu Dec 18 00:39:38 2025 +0100
@@ -1543,6 +1543,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', 'chat'];
for (const button_id of buttons) {
const button = this.buttons[button_id];
@@ -1562,10 +1565,10 @@
return keyword == button_id;
});
}
- set_sensitive(button_id, position && can_be_sensitive);
+ set_sensitive(button_id, sensitive && can_be_sensitive);
}
for (let button_id of ['reload', 'action']) {
- set_sensitive(button_id, record_id !== null);
+ set_sensitive(button_id, sensitive);
}
set_sensitive(
'switch_',
diff -r b7fb8e671bbe -r a8858f7983bf tryton/tryton/gui/window/form.py
--- a/tryton/tryton/gui/window/form.py Tue Dec 16 17:15:40 2025 +0100
+++ b/tryton/tryton/gui/window/form.py Thu Dec 18 00:39:38 2025 +0100
@@ -614,6 +614,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', 'chat']:
button = self.buttons.get(button_id)
@@ -627,9 +628,9 @@
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)
for button_id in ['reload', 'action']:
- set_sensitive(button_id, record_id is not None)
+ set_sensitive(button_id, sensitive)
set_sensitive(
'switch',
(position or view_type == 'form' or next_view_type != 'form')