[IMP] sales_team : remove hardcoded js actions
instead allow to pass context from template(xml) with `data-context` attribute for the crm dashboard.
This commit is contained in:
committed by
Denis Vermylen (dve)
parent
4022a47de2
commit
cdf7d0a115
@@ -6,6 +6,8 @@ var formats = require('web.formats');
|
||||
var Model = require('web.Model');
|
||||
var session = require('web.session');
|
||||
var KanbanView = require('web_kanban.KanbanView');
|
||||
var data = require('web.data');
|
||||
|
||||
|
||||
var QWeb = core.qweb;
|
||||
|
||||
@@ -43,34 +45,14 @@ var SalesTeamDashboardView = KanbanView.extend({
|
||||
});
|
||||
},
|
||||
|
||||
on_dashboard_action_clicked: function(ev){
|
||||
on_dashboard_action_clicked: function(ev) {
|
||||
ev.preventDefault();
|
||||
|
||||
var $action = $(ev.currentTarget);
|
||||
var action_name = $action.attr('name');
|
||||
var action_extra = $action.data('extra');
|
||||
var additional_context = {};
|
||||
|
||||
// TODO: find a better way to add defaults to search view
|
||||
if (action_name === 'calendar.action_calendar_event') {
|
||||
additional_context.search_default_mymeetings = 1;
|
||||
} else if (action_name === 'crm.crm_lead_action_activities') {
|
||||
if (action_extra === 'today') {
|
||||
additional_context.search_default_today = 1;
|
||||
} else if (action_extra === 'this_week') {
|
||||
additional_context.search_default_this_week = 1;
|
||||
} else if (action_extra === 'overdue') {
|
||||
additional_context.search_default_overdue = 1;
|
||||
}
|
||||
} else if (action_name === 'crm.action_your_pipeline') {
|
||||
if (action_extra === 'overdue') {
|
||||
additional_context['search_default_overdue'] = 1;
|
||||
}
|
||||
} else if (action_name === 'crm.crm_opportunity_report_action_graph') {
|
||||
additional_context.search_default_won = 1;
|
||||
}
|
||||
|
||||
this.do_action(action_name, {additional_context: additional_context});
|
||||
var action_context = $action.data('context');
|
||||
this.do_action(action_name, {
|
||||
additional_context: action_context
|
||||
});
|
||||
},
|
||||
|
||||
on_change_input_target: function(e) {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
Today
|
||||
</td>
|
||||
<td class="o_main" title="To Calendar">
|
||||
<a href="#" class="o_dashboard_action" name="calendar.action_calendar_event">
|
||||
<a href="#" class="o_dashboard_action" name="calendar.action_calendar_event" data-context="{'search_default_mymeetings':'1'}">
|
||||
<span class="o_highlight">
|
||||
<t t-if="!show_demo">
|
||||
<t t-esc="values['meeting']['today']"/>
|
||||
@@ -27,7 +27,7 @@
|
||||
</a>
|
||||
</td>
|
||||
<td class="o_main" title="To Activities">
|
||||
<a href="#" class="o_dashboard_action" name="crm.crm_lead_action_activities" data-extra="today">
|
||||
<a href="#" class="o_dashboard_action" name="crm.crm_lead_action_activities" data-context="{'search_default_today':'1'}">
|
||||
<span class="o_highlight">
|
||||
<t t-if="!show_demo">
|
||||
<t t-esc="values['activity']['today']"/>
|
||||
@@ -49,7 +49,7 @@
|
||||
<tr>
|
||||
<td class="o_text">Next 7 days</td>
|
||||
<td class="o_main" title="To Calendar">
|
||||
<a href="#" class="o_dashboard_action" name="calendar.action_calendar_event">
|
||||
<a href="#" class="o_dashboard_action" name="calendar.action_calendar_event" data-context="{'search_default_mymeetings':'1'}">
|
||||
<t t-if="!show_demo">
|
||||
<t t-esc="values['meeting']['next_7_days']"/>
|
||||
</t>
|
||||
@@ -59,7 +59,7 @@
|
||||
</a>
|
||||
</td>
|
||||
<td class="o_main" title="To Activities">
|
||||
<a href="#" class="o_dashboard_action" name="crm.crm_lead_action_activities" data-extra="this_week">
|
||||
<a href="#" class="o_dashboard_action" name="crm.crm_lead_action_activities" data-context="{'search_default_this_week':'1'}">
|
||||
<t t-if="!show_demo">
|
||||
<t t-esc="values['activity']['next_7_days']"/>
|
||||
</t>
|
||||
@@ -74,7 +74,7 @@
|
||||
<td></td>
|
||||
<!-- Hide overdue when there is none -->
|
||||
<td t-if="show_demo or (values and values['activity']['overdue'] != 0)" class="o_warning" title="To Activities">
|
||||
<a href="#" class="o_dashboard_action" name="crm.crm_lead_action_activities" data-extra="overdue">
|
||||
<a href="#" class="o_dashboard_action" name="crm.crm_lead_action_activities" data-context="{'search_default_overdue':'1'}">
|
||||
<t t-if="!show_demo">
|
||||
<t t-esc="values['activity']['overdue']"/> overdue
|
||||
</t>
|
||||
@@ -84,7 +84,7 @@
|
||||
</a>
|
||||
</td>
|
||||
<td t-if="show_demo or (values and values['closing']['overdue'] != 0)" class="o_warning" title="To Opportunities">
|
||||
<a href="#" class="o_dashboard_action" name="crm.action_your_pipeline" data-extra="overdue">
|
||||
<a href="#" class="o_dashboard_action" name="crm.action_your_pipeline" data-context="{'search_default_overdue':'1'}">
|
||||
<t t-if="!show_demo">
|
||||
<t t-esc="values['closing']['overdue']"/> exp. closing
|
||||
</t>
|
||||
@@ -116,7 +116,7 @@
|
||||
</a>
|
||||
</td>
|
||||
<td t-attf-class="#{values and values['won']['target'] and values['won']['this_month'] >= values['won']['target'] ? 'o_main' : 'o_secondary'}" title="To Opportunity Report">
|
||||
<a href="#" class="o_dashboard_action" name="crm.crm_opportunity_report_action_graph">
|
||||
<a href="#" class="o_dashboard_action" name="crm.crm_opportunity_report_action_graph" data-context="{'search_default_won':'1'}">
|
||||
<span class="o_highlight">
|
||||
<t t-if="!show_demo">
|
||||
<t t-esc="widget.render_monetary_field(values['won']['this_month'], values['currency_id'])"/>
|
||||
@@ -192,7 +192,7 @@
|
||||
</a>
|
||||
</td>
|
||||
<td class="o_secondary" title="To Opportunity Report">
|
||||
<a href="#" class="o_dashboard_action" name="crm.crm_opportunity_report_action_graph">
|
||||
<a href="#" class="o_dashboard_action" name="crm.crm_opportunity_report_action_graph" data-context="{'search_default_won':'1'}">
|
||||
<t t-esc="widget.render_monetary_field(values['won']['last_month'], values['currency_id'])"/>
|
||||
</a>
|
||||
</td>
|
||||
|
||||
Reference in New Issue
Block a user