From 1328114dd9b9e1b4f0c7ae1c36be3d81d0354b22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20BEAU?= Date: Fri, 23 Oct 2020 19:23:19 +0200 Subject: [PATCH] [IMP] add smart boutton on form view and action button with metric on tree view --- .../models/attachment_synchronize_task.py | 10 ++ .../views/attachment_queue_views.xml | 21 ++++ .../attachment_synchronize_task_views.xml | 96 +++++++------------ 3 files changed, 65 insertions(+), 62 deletions(-) diff --git a/attachment_synchronize/models/attachment_synchronize_task.py b/attachment_synchronize/models/attachment_synchronize_task.py index 25688717e..a7f03edc3 100644 --- a/attachment_synchronize/models/attachment_synchronize_task.py +++ b/attachment_synchronize/models/attachment_synchronize_task.py @@ -101,6 +101,16 @@ class AttachmentSynchronizeTask(models.Model): "related to this task.\nAn alert will be sent to these emails if any operation " "on these Attachment Queue's file type fails.", ) + count_attachment_failed = fields.Integer(compute="_compute_count_state") + count_attachment_pending = fields.Integer(compute="_compute_count_state") + count_attachment_done = fields.Integer(compute="_compute_count_state") + + def _compute_count_state(self): + for record in self: + for state in ["failed", "pending", "done"]: + record["count_attachment_{}".format(state)] = \ + len(record.attachment_ids.filtered(lambda r: r.state == state)) + def _prepare_attachment_vals(self, data, filename): self.ensure_one() diff --git a/attachment_synchronize/views/attachment_queue_views.xml b/attachment_synchronize/views/attachment_queue_views.xml index b62863594..16f993585 100644 --- a/attachment_synchronize/views/attachment_queue_views.xml +++ b/attachment_synchronize/views/attachment_queue_views.xml @@ -32,4 +32,25 @@ + + attachment.queue + + + + + + + + + + Attachments Queue + ir.actions.act_window + attachment.queue + form + tree,form + + [('task_id', '=', active_id)] + + + diff --git a/attachment_synchronize/views/attachment_synchronize_task_views.xml b/attachment_synchronize/views/attachment_synchronize_task_views.xml index 18f4a2dbc..e25082bdd 100644 --- a/attachment_synchronize/views/attachment_synchronize_task_views.xml +++ b/attachment_synchronize/views/attachment_synchronize_task_views.xml @@ -9,6 +9,30 @@
+ + +