Browse Source

Allow to send mail notification if attachment linked to task fail

12.0-mig-module_prototyper_last
Florian da Costa 5 years ago
committed by David Beal
parent
commit
6b99de7dcf
  1. 9
      attachment_synchronize/models/attachment.py
  2. 4
      attachment_synchronize/models/task.py
  3. 1
      attachment_synchronize/views/task_view.xml

9
attachment_synchronize/models/attachment.py

@ -18,9 +18,14 @@ class IrAttachmentMetadata(models.Model):
'Export File (External location)') 'Export File (External location)')
]) ])
@api.multi
def _run(self): def _run(self):
super(IrAttachmentMetadata, self)._run()
super()._run()
if self.file_type == 'export': if self.file_type == 'export':
path = os.path.join(self.task_id.filepath, self.datas_fname) path = os.path.join(self.task_id.filepath, self.datas_fname)
self.storage_backend_id._add_b64_data(path, self.datas) 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

4
attachment_synchronize/models/task.py

@ -81,6 +81,10 @@ class StorageTask(models.Model):
check_duplicated_files = fields.Boolean( check_duplicated_files = fields.Boolean(
string='Check duplicated files', string='Check duplicated files',
help='If checked, will avoid duplication file import') 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 @api.multi
def _prepare_attachment_vals(self, datas, filename): def _prepare_attachment_vals(self, datas, filename):

1
attachment_synchronize/views/task_view.xml

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

Loading…
Cancel
Save