Set toolbar button sensitiveness based on record id instead of position

This commit is contained in:
Cédric Krier committed 2025-12-18 00:39:38 +01:00
1 parent 077a0825b3
commit 42ad8ae30b
2 files changed
+8 -4

No files matched your search

+5 -2
View File
@@ -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_',
+3 -2
View File
@@ -614,6 +614,7 @@ class Form(TabContent):
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 @@ class Form(TabContent):
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')