details:   https://code.tryton.org/tryton/commit/dc0a158ea439
branch:    default
user:      Cédric Krier <[email protected]>
date:      Wed Aug 26 10:26:45 2026 +0200
description:
        Clear attachment preview when there is no current record

        Closes #15044
diffstat:

 sao/src/tab.js                   |  7 +++----
 tryton/tryton/gui/window/form.py |  6 +++---
 2 files changed, 6 insertions(+), 7 deletions(-)

diffs (33 lines):

diff -r b3f296bc23c9 -r dc0a158ea439 sao/src/tab.js
--- a/sao/src/tab.js    Tue Aug 25 11:15:16 2026 +0200
+++ b/sao/src/tab.js    Wed Aug 26 10:26:45 2026 +0200
@@ -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 -r b3f296bc23c9 -r dc0a158ea439 tryton/tryton/gui/window/form.py
--- a/tryton/tryton/gui/window/form.py  Tue Aug 25 11:15:16 2026 +0200
+++ b/tryton/tryton/gui/window/form.py  Wed Aug 26 10:26:45 2026 +0200
@@ -248,9 +248,9 @@
         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'),

Reply via email to