From 0b24d35a3d59a67e1c2d4b0d2ad978b699251565 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 (grafted from dc0a158ea439898e071602e8dc87fc4767fe76c6) --HG-- branch : 8.0 --- 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 2fab4a0346..be4c5cc81e 100644 --- a/sao/src/tab.js +++ b/sao/src/tab.js @@ -1398,10 +1398,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 0d2a587d6c..06380e0000 100644 --- a/tryton/tryton/gui/window/form.py +++ b/tryton/tryton/gui/window/form.py @@ -245,9 +245,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'),