From 9394d64c2a254f9562e1ebdc2341ceaa108650a9 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 --- trytond/trytond/ir/email_.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/trytond/trytond/ir/email_.py b/trytond/trytond/ir/email_.py index 0fe290a7d3..dcede3d266 100644 --- a/trytond/trytond/ir/email_.py +++ b/trytond/trytond/ir/email_.py @@ -189,11 +189,12 @@ class Email(ResourceAccessMixin, ModelSQL, ModelView): body=body, resource=record) email.save() - attachments_ = [] - for name, data in files: - attachments_.append( - Attachment(resource=email, name=name, data=data)) - Attachment.save(attachments_) + if files: + attachments_ = [] + for name, data in files: + attachments_.append( + Attachment(resource=email, name=name, data=data)) + Attachment.save(attachments_) return email @classmethod