From 0a151fa4beb1cd09f1a38f92a45821a0264bac6c 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 : 7.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 386eb6cc79..e36c08a206 100644 --- a/sao/src/tab.js +++ b/sao/src/tab.js @@ -1324,10 +1324,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 77f2afdf53..5ed7254f71 100644 --- a/tryton/tryton/gui/window/form.py +++ b/tryton/tryton/gui/window/form.py @@ -233,9 +233,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'),