[IMP] mail, contacts: allow to have actions in systray elements
Purpose of this commit is to allow having an icon redirecting to the activity summary view in the partner activities section of systray. This is done by supporting an additional 'actions' list in the activity data given to the systray. It displays small icons that redirect to an Odoo action given its xml ID. This commit is linked to task ID 1882545 and PR #26797.
This commit is contained in:
@@ -17,4 +17,9 @@ class Users(models.Model):
|
||||
if activity['model'] != 'res.partner':
|
||||
continue
|
||||
activity['icon'] = modules.module.get_module_icon('contacts')
|
||||
activity['actions'] = [{
|
||||
'icon': 'fa-clock-o',
|
||||
'name': 'Summary',
|
||||
'action_xmlid': 'contacts.action_contacts_summary'
|
||||
}]
|
||||
return activities
|
||||
|
||||
@@ -34,6 +34,22 @@
|
||||
<field name="act_window_id" ref="action_contacts"/>
|
||||
</record>
|
||||
|
||||
<record id="action_contacts_summary" model="ir.actions.act_window">
|
||||
<field name="name">Contacts</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">res.partner</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">activity,kanban,tree,form</field>
|
||||
<field name="search_view_id" ref="base.view_res_partner_filter"/>
|
||||
<field name="help" type="html">
|
||||
<p class="o_view_nocontent_smiling_face">
|
||||
Create a contact in your address book
|
||||
</p><p>
|
||||
Odoo helps you to easily track all activities related to a customer.
|
||||
</p>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<menuitem name="Contacts"
|
||||
id="menu_contacts"
|
||||
sequence="4"
|
||||
|
||||
@@ -15,6 +15,7 @@ var ActivityMenu = Widget.extend({
|
||||
name: 'activity_menu',
|
||||
template:'mail.systray.ActivityMenu',
|
||||
events: {
|
||||
'click .o_mail_activity_action': '_onActivityActionClick',
|
||||
'click .o_mail_preview': '_onActivityFilterClick',
|
||||
'show.bs.dropdown': '_onActivityMenuShow',
|
||||
},
|
||||
@@ -98,6 +99,17 @@ var ActivityMenu = Widget.extend({
|
||||
// Handlers
|
||||
//------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Redirect to specific action given its xml id
|
||||
* @private
|
||||
* @param {MouseEvent} ev
|
||||
*/
|
||||
_onActivityActionClick: function (ev) {
|
||||
ev.stopPropagation();
|
||||
var actionXmlid = $(ev.currentTarget).data('action_xmlid');
|
||||
this.do_action(actionXmlid);
|
||||
},
|
||||
|
||||
/**
|
||||
* Redirect to particular model view
|
||||
* @private
|
||||
|
||||
@@ -327,9 +327,19 @@
|
||||
.o_preview_title {
|
||||
display: flex;
|
||||
.o_preview_name {
|
||||
flex: 0 1 auto;
|
||||
flex: 0 0 auto;
|
||||
@include o-text-overflow;
|
||||
}
|
||||
.o_mail_activity_action_buttons {
|
||||
display: flex;
|
||||
flex: 1 1 auto;
|
||||
flex-flow: row-reverse wrap;
|
||||
}
|
||||
.o_mail_activity_action {
|
||||
padding-top: 0px;
|
||||
padding-bottom: 0px;
|
||||
padding-right: 0px;
|
||||
}
|
||||
.o_preview_counter {
|
||||
flex: 1 1 auto;
|
||||
}
|
||||
|
||||
@@ -78,6 +78,17 @@
|
||||
<span class="o_preview_name">
|
||||
<t t-esc="activity.name"/>
|
||||
</span>
|
||||
<div t-if="activity.actions" class="o_mail_activity_action_buttons">
|
||||
<t t-foreach="activity.actions" t-as="action">
|
||||
<button type="button"
|
||||
t-att-title="action.name"
|
||||
t-att-class="'o_mail_activity_action btn btn-link fa ' + action.icon"
|
||||
t-att-data-action_xmlid="action.action_xmlid"
|
||||
t-att-data-res_model="activity.model"
|
||||
t-att-data-model_name="activity.name">
|
||||
</button>
|
||||
</t>
|
||||
</div>
|
||||
</div>
|
||||
<div t-if="activity and activity.type == 'activity'">
|
||||
<button t-if="activity.overdue_count" type="button" class="btn btn-link o_activity_filter_button mr16" t-att-data-res_model="activity.model" t-att-data-model_name="activity.name" data-filter='overdue'><t t-esc="activity.overdue_count"/> Late </button>
|
||||
|
||||
Reference in New Issue
Block a user