From 942f04b8243f330d4dc618d8ff576f38d7dda350 Mon Sep 17 00:00:00 2001 From: Alessio Renda Date: Wed, 14 Feb 2024 10:30:45 +0100 Subject: [PATCH] [FIX] attachment_preview: fix get_binary_extension --- attachment_preview/models/ir_attachment.py | 2 ++ attachment_preview/tests/test_attachment_preview.py | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/attachment_preview/models/ir_attachment.py b/attachment_preview/models/ir_attachment.py index ca294690..20a97b07 100644 --- a/attachment_preview/models/ir_attachment.py +++ b/attachment_preview/models/ir_attachment.py @@ -41,6 +41,8 @@ class IrAttachment(models.Model): ids_to_browse = [_id for _id in ids_to_browse if _id not in result] for this in self.env[model].with_context(bin_size=True).browse(ids_to_browse): result[this.id] = False + if not this[binary_field]: + continue try: import magic diff --git a/attachment_preview/tests/test_attachment_preview.py b/attachment_preview/tests/test_attachment_preview.py index c5fedd86..4b033ae7 100644 --- a/attachment_preview/tests/test_attachment_preview.py +++ b/attachment_preview/tests/test_attachment_preview.py @@ -35,3 +35,11 @@ class TestAttachmentPreview(TransactionCase): "ir.module.module", module.id, "icon_image" ) self.assertTrue(res3) + + module = ( + self.env["ir.ui.menu"].search([]).filtered(lambda m: not m.web_icon_data)[0] + ) + res4 = self.env["ir.attachment"].get_binary_extension( + "ir.ui.menu", module.id, "web_icon_data" + ) + self.assertFalse(res4)