Allow to send email without files to attach

Closes #12645
(grafted from 177d9695220f1ec64eab311e11ff7c97b1880cfb)

--HG--
branch : 6.0
This commit is contained in:
Maxime Richez
2023-10-16 16:48:40 +02:00
parent 29d86ae0ad
commit a8d28ddca8
+7 -6
View File
@@ -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