From 6d1f9a2000a2e52da4e4eda253c1dac7a5d4f9ee Mon Sep 17 00:00:00 2001 From: root Date: Thu, 12 May 2022 13:35:11 +0000 Subject: [PATCH] [ADD] mail: quick-open related record from email Current behavior before PR: You have to find the right menu/view and then take over the ID stored on the email 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. Task-2868230 closes odoo/odoo#91228 Signed-off-by: Thibault Delavallee (tde) --- addons/mail/models/mail_mail.py | 11 +++++++++++ addons/mail/views/mail_mail_views.xml | 5 +++++ 2 files changed, 16 insertions(+) diff --git a/addons/mail/models/mail_mail.py b/addons/mail/models/mail_mail.py index 347836c095f..01dc0adc9a1 100644 --- a/addons/mail/models/mail_mail.py +++ b/addons/mail/models/mail_mail.py @@ -158,6 +158,17 @@ class MailMail(models.Model): def action_retry(self): self.filtered(lambda mail: mail.state == 'exception').mark_outgoing() + 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', + } + def mark_outgoing(self): return self.write({'state': 'outgoing'}) diff --git a/addons/mail/views/mail_mail_views.xml b/addons/mail/views/mail_mail_views.xml index 1b1cb862061..d599b404d5c 100644 --- a/addons/mail/views/mail_mail_views.xml +++ b/addons/mail/views/mail_mail_views.xml @@ -13,6 +13,11 @@ +
+