diff --git a/attachment_synchronize/models/attachment_queue.py b/attachment_synchronize/models/attachment_queue.py index 7a8e3390d..1047ee9f1 100644 --- a/attachment_synchronize/models/attachment_queue.py +++ b/attachment_synchronize/models/attachment_queue.py @@ -2,7 +2,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). import os -from odoo import models, fields +from odoo import api, models, fields class AttachmentQueue(models.Model): @@ -30,3 +30,9 @@ class AttachmentQueue(models.Model): if self.task_id.emails: res = self.task_id.emails return res + + @api.onchange("task_id") + def onchange_task_id(self): + for attachment in self: + if attachment.task_id.method_type == "export": + attachment.file_type = "export" diff --git a/attachment_synchronize/models/attachment_synchronize_task.py b/attachment_synchronize/models/attachment_synchronize_task.py index 5d9239938..d1ad764c9 100644 --- a/attachment_synchronize/models/attachment_synchronize_task.py +++ b/attachment_synchronize/models/attachment_synchronize_task.py @@ -100,9 +100,11 @@ class AttachmentSynchronizeTask(models.Model): "when excuting the files linked to this task", ) - def toogle_enabled(self): + @api.onchange("method_type") + def onchange_method_type(self): for task in self: - task.enabled = not task.enabled + if task.method_type == "export": + task.file_type = "export" def _prepare_attachment_vals(self, data, filename): self.ensure_one() @@ -196,17 +198,14 @@ class AttachmentSynchronizeTask(models.Model): ) return list(set(filenames) - set(imported)) + def run_export(self): + for task in self: + task.attachment_ids.filtered(lambda a: a.state == "pending").run() + def button_toogle_enabled(self): for rec in self: rec.enabled = not rec.enabled def button_duplicate_record(self): self.ensure_one() - record = self.copy({"enabled": False}) - return { - "type": "ir.actions.act_window", - "res_model": record.backend_id._name, - "target": "current", - "view_mode": "form", - "res_id": record.backend_id.id, - } + self.copy({"enabled": False}) diff --git a/attachment_synchronize/views/attachment_synchronize_task_views.xml b/attachment_synchronize/views/attachment_synchronize_task_views.xml index 4ca32bbc1..13760d46b 100644 --- a/attachment_synchronize/views/attachment_synchronize_task_views.xml +++ b/attachment_synchronize/views/attachment_synchronize_task_views.xml @@ -7,9 +7,12 @@
+
+
-