From a8d28ddca86b2e77fc71b1fcb4accd8fbf9ce990 Mon Sep 17 00:00:00 2001 From: Maxime Richez Date: Mon, 16 Oct 2023 16:48:40 +0200 Subject: [PATCH] Allow to send email without files to attach Closes #12645 (grafted from 177d9695220f1ec64eab311e11ff7c97b1880cfb) --HG-- branch : 6.0 --- trytond/trytond/ir/email_.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/trytond/trytond/ir/email_.py b/trytond/trytond/ir/email_.py index 66c4bc9166..767093cddc 100644 --- a/trytond/trytond/ir/email_.py +++ b/trytond/trytond/ir/email_.py @@ -191,12 +191,13 @@ class Email(ResourceAccessMixin, ModelSQL, ModelView): body=body, resource=record) email.save() - with Transaction().set_context(_check_access=False): - attachments_ = [] - for name, data in files: - attachments_.append( - Attachment(resource=email, name=name, data=data)) - Attachment.save(attachments_) + if files: + with Transaction().set_context(_check_access=False): + attachments_ = [] + for name, data in files: + attachments_.append( + Attachment(resource=email, name=name, data=data)) + Attachment.save(attachments_) return email @classmethod