From 6b99de7dcf23e4c7f855de127f83732eba256d22 Mon Sep 17 00:00:00 2001 From: Florian da Costa Date: Mon, 10 Feb 2020 14:18:57 +0100 Subject: [PATCH] Allow to send mail notification if attachment linked to task fail --- attachment_synchronize/models/attachment.py | 9 +++++++-- attachment_synchronize/models/task.py | 4 ++++ attachment_synchronize/views/task_view.xml | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/attachment_synchronize/models/attachment.py b/attachment_synchronize/models/attachment.py index 231cd5181..926b5a6e6 100644 --- a/attachment_synchronize/models/attachment.py +++ b/attachment_synchronize/models/attachment.py @@ -18,9 +18,14 @@ class IrAttachmentMetadata(models.Model): 'Export File (External location)') ]) - @api.multi def _run(self): - super(IrAttachmentMetadata, self)._run() + super()._run() if self.file_type == 'export': path = os.path.join(self.task_id.filepath, self.datas_fname) self.storage_backend_id._add_b64_data(path, self.datas) + + def _get_failure_emails(self): + res = super()._get_failure_emails() + if self.task_id.emails: + res = self.task_id.emails + return res diff --git a/attachment_synchronize/models/task.py b/attachment_synchronize/models/task.py index 10ac78d55..4641a1b1d 100644 --- a/attachment_synchronize/models/task.py +++ b/attachment_synchronize/models/task.py @@ -81,6 +81,10 @@ class StorageTask(models.Model): check_duplicated_files = fields.Boolean( string='Check duplicated files', help='If checked, will avoid duplication file import') + emails = fields.Char( + string="Emails", + help="list of email which should be notified in case of failure " + "when excuting the files linked to this task") @api.multi def _prepare_attachment_vals(self, datas, filename): diff --git a/attachment_synchronize/views/task_view.xml b/attachment_synchronize/views/task_view.xml index 198dacb83..9195143aa 100644 --- a/attachment_synchronize/views/task_view.xml +++ b/attachment_synchronize/views/task_view.xml @@ -21,6 +21,7 @@ +