From acc3586debbc89bf57a745a7c89fd286faafe8cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 26 Aug 2026 10:26:45 +0200 Subject: [PATCH] Clear attachment preview when there is no current record Closes #15044 --- sao/src/tab.js | 7 +++---- tryton/tryton/gui/window/form.py | 6 +++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/sao/src/tab.js b/sao/src/tab.js index 48930b129d..678fb4322f 100644 --- a/sao/src/tab.js +++ b/sao/src/tab.js @@ -1419,10 +1419,9 @@ return; } var record = this.screen.current_record; - if (!record) { - return; - } - var resource = record.model.name + ',' + record.id; + var resource = ( + record ? record.model.name + ',' + record.id : + this.screen.model_name + ',-1'); var domain = [ ['resource', '=', resource], ['type', '=', 'data'], diff --git a/tryton/tryton/gui/window/form.py b/tryton/tryton/gui/window/form.py index e7e80cf6fd..32cae865f2 100644 --- a/tryton/tryton/gui/window/form.py +++ b/tryton/tryton/gui/window/form.py @@ -248,9 +248,9 @@ class Form(TabContent): if not self.attachment_screen: return record = self.screen.current_record - if not record: - return - resource = '%s,%s' % (record.model_name, record.id) + resource = '%s,%s' % ( + (record.model_name, record.id) if record + else (self.screen.model_name, -1)) domain = [ ('resource', '=', resource), ('type', '=', 'data'),