From 025b726e8e58bf566f8edfb728d787054ea0e67a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 10 Jun 2024 17:13:03 +0200 Subject: [PATCH] Always update state of delete and undelete buttons in window form Closes #13323 (grafted from 377fcba9fba2d39973067915f72848fd01bce7ed) --HG-- branch : 6.0 --- sao/src/window.js | 10 ++++++---- tryton/tryton/gui/window/win_form.py | 8 +++++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/sao/src/window.js b/sao/src/window.js index 850919c9d3..6d3432bc1a 100644 --- a/sao/src/window.js +++ b/sao/src/window.js @@ -354,10 +354,12 @@ } this.but_next.prop('disabled', data[0] >= data[1]); this.but_previous.prop('disabled', data[0] <= 1); - if (access.delete && !readonly && deletable) { - this.but_del.prop('disabled', false); - this.but_undel.prop('disabled', false); - } + this.but_del.prop( + 'disabled', + readonly || + !access.delete || + !deletable); + this.but_undel.prop('disabled', readonly); } else { this.but_del.prop('disabled', true); this.but_undel.prop('disabled', true); diff --git a/tryton/tryton/gui/window/win_form.py b/tryton/tryton/gui/window/win_form.py index eaacffe5d7..f8027d2b7b 100644 --- a/tryton/tryton/gui/window/win_form.py +++ b/tryton/tryton/gui/window/win_form.py @@ -368,9 +368,11 @@ class WinForm(NoModal, InfoBar): self.but_pre.set_sensitive(True) else: self.but_pre.set_sensitive(False) - if access['delete'] and not readonly and deletable: - self.but_del.set_sensitive(True) - self.but_undel.set_sensitive(True) + self.but_del.set_sensitive(bool( + not readonly + and access['delete'] + and deletable)) + self.but_undel.set_sensitive(bool(not readonly)) else: self.but_del.set_sensitive(False) self.but_undel.set_sensitive(False)