Browse Source

[IMP] rename task emails into failure_emails and improve tasks views

12.0-mig-module_prototyper_last
clementmbr 5 years ago
committed by David Beal
parent
commit
3bbf135d52
  1. 4
      attachment_synchronize/models/attachment_queue.py
  2. 27
      attachment_synchronize/models/attachment_synchronize_task.py
  3. 29
      attachment_synchronize/views/attachment_synchronize_task_views.xml

4
attachment_synchronize/models/attachment_queue.py

@ -28,8 +28,8 @@ class AttachmentQueue(models.Model):
def _get_failure_emails(self):
res = super()._get_failure_emails()
if self.task_id.emails:
res = self.task_id.emails
if self.task_id.failure_emails:
res = self.task_id.failure_emails
return res
@api.onchange("task_id")

27
attachment_synchronize/models/attachment_synchronize_task.py

@ -51,10 +51,11 @@ class AttachmentSynchronizeTask(models.Model):
name = fields.Char(required=True)
method_type = fields.Selection(
[("import", "Import"), ("export", "Export")], required=True
[("import", "Import Task"), ("export", "Export Task")], required=True
)
pattern = fields.Char(
help="Used to select the files to be imported. Import all the files if empty."
string="Selection Pattern",
help="Used to select the files to be imported. If empty, import all the files.",
)
filepath = fields.Char(
string="File Path", help="Path to imported/exported files in the Backend"
@ -83,16 +84,20 @@ class AttachmentSynchronizeTask(models.Model):
file_type = fields.Selection(
selection=[],
string="File Type",
help="The file type indicates what Odoo will do with the files once imported",
help="The file type allows Odoo to recognize what to do with the files "
"once imported.",
)
enabled = fields.Boolean("Enabled", default=True)
avoid_duplicated_files = fields.Boolean(
string="Avoid duplicated files importation",
help="If checked, will avoid duplication file import",
string="Avoid importing duplicated files",
help="If checked, a file will not be imported if there is already an "
"Attachment Queue with the same name.",
)
emails = fields.Char(
string="Notification Emails",
help="These emails will receive a notification in case of the task failure",
failure_emails = fields.Char(
string="Failure Emails",
help="Used to fill the field 'Failure Emails' in the task related "
"Attachments Queues.\nThese emails will be notified if any operation on these "
"Attachment Queue's file type fails.",
)
def _prepare_attachment_vals(self, data, filename):
@ -111,14 +116,16 @@ class AttachmentSynchronizeTask(models.Model):
try:
template = mako_template_env.from_string(tools.ustr(template))
except Exception:
_logger.exception("Failed to load template %r", template)
_logger.exception("Failed to load template '{}'".format(template))
variables = {"obj": record}
try:
render_result = template.render(variables)
except Exception:
_logger.exception(
"Failed to render template %r using values %r" % (template, variables)
"Failed to render template '{}'' using values '{}'".format(
template, variables
)
)
render_result = u""
if render_result == u"False":

29
attachment_synchronize/views/attachment_synchronize_task_views.xml

@ -12,7 +12,7 @@
</header>
<sheet>
<div class="oe_button_box" name="button_box">
<button name="button_toogle_enabled" type="object" class="oe_stat_button" icon="fa-check-square">
<button name="button_toogle_enabled" type="object" class="oe_stat_button" icon="fa-archive">
<field
name="enabled"
widget="boolean_button"
@ -26,19 +26,20 @@
</button>
</div>
<field name="method_type" invisible="1"/>
<div class="oe_title" colspan="4">
<div class="oe_title">
<label class="oe_edit_only" for="name" string="Name"/>
<h1>
<field name="name" class="oe_inline"/>
</h1>
<field name="create_date" invisible="1" />
<field name="method_type" widget="radio" options="{'horizontal': true}" attrs="{'readonly':[('create_date', '!=', False)]}"/>
</div>
<group class="col-12 col-lg-6">
<field name="method_type"/>
<group string="Storage Location" class="col-12 col-lg-6">
<field name="backend_id"/>
<field name="filepath"/>
<field name="pattern" attrs="{'invisible':[('method_type','!=','import')]}"/>
</group>
<group name="action" string="Importation Settings" attrs="{'invisible':[('method_type','!=','import')]}" class="col-12 col-lg-6">
<group name="action" string="Importation" attrs="{'invisible':[('method_type','!=','import')]}" class="col-12 col-lg-6">
<field name="avoid_duplicated_files" />
<field name="after_import" />
<field name="move_path" colspan="4" attrs="{'invisible':[('after_import','!=','move'), ('after_import','!=','move_rename')]}"/>
@ -47,7 +48,7 @@
<group string="Attachments">
<group>
<field name="file_type" attrs="{'invisible':[('method_type','!=','import')]}" />
<field name="emails" attrs="{'invisible':[('method_type','!=','import')]}" />
<field name="failure_emails" />
</group>
<field name="attachment_ids" domain="[('task_id', '=', id)]" nolabel="1" attrs="{'invisible':[('method_type','!=','export')]}"/>
</group>
@ -61,14 +62,14 @@
<field name="arch" type="xml">
<tree string="Tasks" decoration-muted="enabled == False">
<field name="name" select="1"/>
<field name="pattern"/>
<field name="backend_id"/>
<field name="filepath"/>
<field name="move_path"/>
<field name="pattern"/>
<field name="after_import"/>
<field name="backend_id"/>
<field name="move_path"/>
<field name="enabled" invisible="1"/>
<button name="button_duplicate_record" type="object" title="Copy" class="fa fa-clone"/>
<button name="button_toogle_enabled" type="object" title="Enable" class="fa fa-check-square"/>
<button name="button_duplicate_record" type="object" string="Copy" icon="fa-clone"/>
<button name="button_toogle_enabled" type="object" string="Enable" icon="fa-archive"/>
</tree>
</field>
</record>
@ -78,11 +79,11 @@
<field name="arch" type="xml">
<tree string="Tasks" decoration-muted="enabled == False">
<field name="name" select="1"/>
<field name="filepath"/>
<field name="backend_id"/>
<field name="filepath"/>
<field name="enabled" invisible="1"/>
<button name="button_duplicate_record" type="object" title="Copy" class="fa fa-clone"/>
<button name="button_toogle_enabled" type="object" title="Enable" class="fa fa-check-square"/>
<button name="button_duplicate_record" type="object" string="Copy" icon="fa-clone"/>
<button name="button_toogle_enabled" type="object" string="Enable" icon="fa-archive"/>
</tree>
</field>
</record>

Loading…
Cancel
Save