diff --git a/sao/src/tab.js b/sao/src/tab.js index d2c1e6a60e..0f85e951ba 100644 --- a/sao/src/tab.js +++ b/sao/src/tab.js @@ -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 --git a/tryton/tryton/gui/window/form.py b/tryton/tryton/gui/window/form.py index bdb6ca7cfc..3d9ac50b6f 100644 --- a/tryton/tryton/gui/window/form.py +++ b/tryton/tryton/gui/window/form.py @@ -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')