From 342d5eb6ed238cc568806e5d7771b93e905189ec 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 --- 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 d8d319ebb7..67cff3270b 100644 --- a/sao/src/window.js +++ b/sao/src/window.js @@ -414,10 +414,12 @@ } this.but_next.prop('disabled', position >= size); this.but_previous.prop('disabled', position <= 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 cae4ffbcb0..3ee186e131 100644 --- a/tryton/tryton/gui/window/win_form.py +++ b/tryton/tryton/gui/window/win_form.py @@ -373,9 +373,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)