From 2fb4da22eca5d9261996aacbefd9bdb33b3ecd92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 16 Nov 2023 18:23:14 +0100 Subject: [PATCH] Select first record when refreshing attachment preview Since ab82d479eca1 no record is set when displaying screen. Closes #12756 (grafted from e40c63e467b0f878b54594729c7e07458f12ad71) --HG-- branch : 7.0 --- sao/src/tab.js | 8 +++++++- tryton/tryton/gui/window/form.py | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/sao/src/tab.js b/sao/src/tab.js index 038c0185de..3711eee130 100644 --- a/sao/src/tab.js +++ b/sao/src/tab.js @@ -1309,7 +1309,13 @@ if (!Sao.common.compare(this.attachment_screen.domain, domain) || force) { this.attachment_screen.domain = domain; - this.attachment_screen.search_filter(); + this.attachment_screen.search_filter().then(() => { + const group = this.attachment_screen.group; + if (group.length) { + this.attachment_screen.current_record = group[0]; + this.attachment_screen.display(); + } + }); } }, note: function() { diff --git a/tryton/tryton/gui/window/form.py b/tryton/tryton/gui/window/form.py index 63ba093f6d..8036ca5318 100644 --- a/tryton/tryton/gui/window/form.py +++ b/tryton/tryton/gui/window/form.py @@ -240,6 +240,10 @@ class Form(TabContent): if self.attachment_screen.domain != domain or force: self.attachment_screen.domain = domain self.attachment_screen.search_filter() + group = self.attachment_screen.group + if group: + self.attachment_screen.current_record = group[0] + self.attachment_screen.display() def sig_note(self, widget=None): record = self.screen.current_record