mail_usability: improve mail_activity views
This commit is contained in:
@@ -1,2 +1,3 @@
|
||||
from . import res_partner
|
||||
from . import mail_activity
|
||||
from . import mail_template
|
||||
|
||||
24
mail_usability/models/mail_activity.py
Normal file
24
mail_usability/models/mail_activity.py
Normal file
@@ -0,0 +1,24 @@
|
||||
# Copyright 2023 Akretion France (http://www.akretion.com).
|
||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class MailActivity(models.Model):
|
||||
_inherit = 'mail.activity'
|
||||
|
||||
res_model_name = fields.Char(related='res_model_id.name', string='Document Type')
|
||||
|
||||
def jump_to_record(self):
|
||||
self.ensure_one()
|
||||
action = {}
|
||||
if self.res_id and self.res_model and self.res_name:
|
||||
action.update({
|
||||
'type': 'ir.actions.act_window',
|
||||
'name': self.res_name,
|
||||
'res_model': self.res_model,
|
||||
'view_mode': 'form',
|
||||
'res_id': self.res_id,
|
||||
})
|
||||
return action
|
||||
@@ -26,8 +26,27 @@
|
||||
<field name="summary" position="after">
|
||||
<field name="user_id" optional="show" widget="many2one_avatar_user"/>
|
||||
</field>
|
||||
<field name="res_name" position="before">
|
||||
<button name="jump_to_record" type="object" attrs="{'invisible': [('res_name', '=', False)]}" icon="fa-binoculars" string="Go to source" class="text-warning" invisible="not context.get('mail_activity_main_view')"/>
|
||||
</field>
|
||||
<field name="res_name" position="after">
|
||||
<field name="res_model_name" invisible="not context.get('mail_activity_main_view')"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="mail_activity_view_form_popup" model="ir.ui.view">
|
||||
<field name="model">mail.activity</field>
|
||||
<field name="inherit_id" ref="mail.mail_activity_view_form_popup"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="activity_type_id" position="before">
|
||||
<field name="res_name" invisible="not context.get('mail_activity_main_view')"/>
|
||||
<field name="res_model_name" invisible="not context.get('mail_activity_main_view')"/>
|
||||
</field>
|
||||
<button name="action_close_dialog" position="before">
|
||||
<button name="jump_to_record" type="object" attrs="{'invisible': [('res_id', '=', False)]}" class="btn-primary" string="Go to source" invisible="not context.get('mail_activity_main_view')"/>
|
||||
</button>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
|
||||
Reference in New Issue
Block a user