From 50f6e5f2beb1320a2c59d41fd45befa32df9aff3 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 4 Oct 2021 07:45:48 +0000 Subject: [PATCH] [IMP] mail: quick-open related record from message Before this commit if you found a message and wanted to open the related record you would need to find it manually by finding the right view and then using the ID stored on the message to open it. 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. Ref Task-2660873 closes odoo/odoo#77675 closes odoo/odoo#77803 Signed-off-by: Thibault Delavallee (tde) --- addons/mail/models/mail_message.py | 11 +++++++++++ addons/mail/views/mail_message_views.xml | 5 +++++ 2 files changed, 16 insertions(+) diff --git a/addons/mail/models/mail_message.py b/addons/mail/models/mail_message.py index a93b7c9241c..9c45f4a6be7 100644 --- a/addons/mail/models/mail_message.py +++ b/addons/mail/models/mail_message.py @@ -691,6 +691,17 @@ class Message(models.Model): self.update(attachement_values) thread._message_update_content_after_hook(self) + 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.model, + 'target': 'current', + 'type': 'ir.actions.act_window', + 'view_mode': 'form', + } + # ------------------------------------------------------ # DISCUSS API # ------------------------------------------------------ diff --git a/addons/mail/views/mail_message_views.xml b/addons/mail/views/mail_message_views.xml index f557f164824..401b4906a7b 100644 --- a/addons/mail/views/mail_message_views.xml +++ b/addons/mail/views/mail_message_views.xml @@ -25,6 +25,11 @@
+
+