Allow to send mail notification if attachment linked to task fail

pull/2632/head
Florian da Costa 2020-02-10 14:18:57 +01:00
parent 31e608993b
commit d91060157d
3 changed files with 12 additions and 2 deletions

View File

@ -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

View File

@ -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):

View File

@ -21,6 +21,7 @@
<field name="pattern" attrs="{'invisible':[('method_type','!=','import')]}"/>
<field name="filepath"/>
<field name="check_duplicated_files" />
<field name="emails"/>
</group>
<group name="action" string="Action">
<field name="after_import" attrs="{'invisible':[('method_type','!=','import')]}"/>