[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) <tde@openerp.com>
This commit is contained in:
root
2022-05-31 11:06:52 +02:00
committed by Thibault Delavallée
parent f9a8072dbf
commit 6d1f9a2000
2 changed files with 16 additions and 0 deletions
+11
View File
@@ -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'})
+5
View File
@@ -13,6 +13,11 @@
<field name="state" widget="statusbar" statusbar_visible="outgoing,sent,received,exception,cancel"/>
</header>
<sheet>
<div class="oe_button_box" name="button_box">
<button name="action_open_document" string="Open Document"
type="object" class="oe_link" icon="fa-file-text-o"
attrs="{'invisible': ['|', ('model', '=', False), ('res_id', '=', 0)]}"/>
</div>
<field name="mail_message_id_int" required="0" invisible="1"/>
<label for="subject" class="oe_edit_only"/>
<h2><field name="subject"/></h2>