From 4c6a010730423a2aa7b19b61d2fcd8f07a630af6 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 12 May 2022 13:39:54 +0000 Subject: [PATCH] [ADD] mail: quick-open related record from activity Current behavior before PR: You have to find the right menu/view and then take over the ID stored on the activity (through export) to find back the record. This is annoying, painful and error prone. Desired behavior after PR is merged: By adding a smartbutton the user can quick-navigate to the related record in a second. This allows for quickly finding and opening records which is usually handy when debugging things or finding back related records. Task-2868230 closes odoo/odoo#91230 Signed-off-by: Thibault Delavallee (tde) --- addons/mail/models/mail_activity.py | 11 +++++++++++ addons/mail/views/mail_activity_views.xml | 5 +++++ 2 files changed, 16 insertions(+) diff --git a/addons/mail/models/mail_activity.py b/addons/mail/models/mail_activity.py index 79601fe3b19..01f4e78cb2a 100644 --- a/addons/mail/models/mail_activity.py +++ b/addons/mail/models/mail_activity.py @@ -568,6 +568,17 @@ class MailActivity(models.Model): def action_close_dialog(self): return {'type': 'ir.actions.act_window_close'} + def action_open_document(self): + """ Opens the related record based on the model and ID """ + self.ensure_one() + return { + 'res_id': self.res_id, + 'res_model': self.res_model, + 'target': 'current', + 'type': 'ir.actions.act_window', + 'view_mode': 'form', + } + def activity_format(self): activities = self.read() mail_template_ids = set([template_id for activity in activities for template_id in activity["mail_template_ids"]]) diff --git a/addons/mail/views/mail_activity_views.xml b/addons/mail/views/mail_activity_views.xml index 460b9782989..6ed716a45d5 100644 --- a/addons/mail/views/mail_activity_views.xml +++ b/addons/mail/views/mail_activity_views.xml @@ -99,6 +99,11 @@
+
+