Skip to content

Commit

Permalink
[ADD] mail: quick-open related record from activity
Browse files Browse the repository at this point in the history
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#91230

Signed-off-by: Thibault Delavallee (tde) <[email protected]>
  • Loading branch information
Yenthe666 authored and tde-banana-odoo committed May 31, 2022
1 parent 6d1f9a2 commit 4c6a010
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
11 changes: 11 additions & 0 deletions addons/mail/models/mail_activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,17 @@ def _action_done(self, feedback=False, attachment_ids=None):
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"]])
Expand Down
5 changes: 5 additions & 0 deletions addons/mail/views/mail_activity_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@
<field name="arch" type="xml">
<form string="Log an Activity" create="false">
<sheet string="Activity">
<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': ['|', ('res_model', '=', False), ('res_id', '=', 0)]}"/>
</div>
<group invisible="1">
<field name="activity_category" invisible="1" />
<field name="res_model" invisible="1"/>
Expand Down

0 comments on commit 4c6a010

Please sign in to comment.