diff --git a/addons/crm/models/crm_lead.py b/addons/crm/models/crm_lead.py
index 510aec448c4..121f0c52e72 100644
--- a/addons/crm/models/crm_lead.py
+++ b/addons/crm/models/crm_lead.py
@@ -1057,135 +1057,6 @@ class Lead(models.Model):
message = _("Meeting scheduled at '%s'
Subject: %s
Duration: %s hours") % (html_time, meeting_subject, duration)
return self.message_post(body=message)
- # ----------------------------------------
- # Sales Team Dashboard
- # ----------------------------------------
-
- @api.model
- def retrieve_sales_dashboard(self):
- """ Fetch data to setup Sales Dashboard """
- result = {
- 'meeting': {
- 'today': 0,
- 'next_7_days': 0,
- },
- 'activity': {
- 'today': 0,
- 'overdue': 0,
- 'next_7_days': 0,
- },
- 'closing': {
- 'today': 0,
- 'overdue': 0,
- 'next_7_days': 0,
- },
- 'done': {
- 'this_month': 0,
- 'last_month': 0,
- },
- 'won': {
- 'this_month': 0,
- 'last_month': 0,
- },
- 'nb_opportunities': 0,
- }
-
- today = fields.Date.from_string(fields.Date.context_today(self))
-
- opportunities = self.search([('type', '=', 'opportunity'), ('user_id', '=', self._uid)])
-
- for opp in opportunities:
- # Expected closing
- if opp.activity_date_deadline:
- if opp.date_deadline:
- date_deadline = fields.Date.from_string(opp.date_deadline)
- if date_deadline == today:
- result['closing']['today'] += 1
- if today <= date_deadline <= today + timedelta(days=7):
- result['closing']['next_7_days'] += 1
- if date_deadline < today and not opp.date_closed:
- result['closing']['overdue'] += 1
- # Next activities
- for activity in opp.activity_ids:
- date_deadline = fields.Date.from_string(activity.date_deadline)
- if date_deadline == today:
- result['activity']['today'] += 1
- if today <= date_deadline <= today + timedelta(days=7):
- result['activity']['next_7_days'] += 1
- if date_deadline < today:
- result['activity']['overdue'] += 1
- # Won in Opportunities
- if opp.date_closed and opp.stage_id.is_won:
- date_closed = fields.Date.from_string(opp.date_closed)
- if today.replace(day=1) <= date_closed <= today:
- if opp.planned_revenue:
- result['won']['this_month'] += opp.planned_revenue
- elif today + relativedelta(months=-1, day=1) <= date_closed < today.replace(day=1):
- if opp.planned_revenue:
- result['won']['last_month'] += opp.planned_revenue
-
- result['nb_opportunities'] = len(opportunities)
-
- # crm.activity is a very messy model so we need to do that in order to retrieve the actions done.
- self._cr.execute("""
- SELECT
- mail_message.id,
- mail_message.subtype_id,
- mail_message.mail_activity_type_id,
- mail_message.date,
- crm_lead.user_id,
- crm_lead.type
- FROM mail_message
- LEFT JOIN crm_lead ON (mail_message.res_id = crm_lead.id)
- INNER JOIN mail_activity_type activity_type ON (mail_message.mail_activity_type_id = activity_type.id)
- WHERE
- (mail_message.model = 'crm.lead') AND (crm_lead.user_id = %s) AND (crm_lead.type = 'opportunity')
- """, (self._uid,))
- activites_done = self._cr.dictfetchall()
- for activity in activites_done:
- if activity['date']:
- date_act = fields.Date.from_string(activity['date'])
- if today.replace(day=1) <= date_act <= today:
- result['done']['this_month'] += 1
- elif today + relativedelta(months=-1, day=1) <= date_act < today.replace(day=1):
- result['done']['last_month'] += 1
-
- # Meetings
- min_date = fields.Datetime.now()
- max_date = fields.Datetime.to_string(datetime.now() + timedelta(days=8))
- meetings_domain = [
- ('start', '>=', min_date),
- ('start', '<=', max_date),
- ('partner_ids', 'in', [self.env.user.partner_id.id])
- ]
- meetings = self.env['calendar.event'].search(meetings_domain)
- for meeting in meetings:
- if meeting['start']:
- start = meeting['start']
- if start == today:
- result['meeting']['today'] += 1
- if today <= start <= today + timedelta(days=7):
- result['meeting']['next_7_days'] += 1
-
- result['done']['target'] = self.env.user.target_sales_done
- result['won']['target'] = self.env.user.target_sales_won
- result['currency_id'] = self.env.company.currency_id.id
-
- return result
-
- @api.model
- def modify_target_sales_dashboard(self, target_name, target_value):
- """ Update the user objectives (`target_sales_done`, target_sales_won`
- and `target_sales_invoiced` fields).
- :param target_name : part of the fields name to update
- :param target_value : value of the field to update
- """
- if target_name in ['won', 'done', 'invoiced']:
- # bypass rights, since self.env.user is browsed as SUPERUSER_ID
- self.env.user.write({'target_sales_' + target_name: target_value})
- else:
- raise UserError(_('This target does not exist.'))
-
# ----------------------------------------
# Mail Gateway
# ----------------------------------------
diff --git a/addons/crm/static/tests/sales_team_dashboard_tests.js b/addons/crm/static/tests/sales_team_dashboard_tests.js
deleted file mode 100644
index 7cb352a30ae..00000000000
--- a/addons/crm/static/tests/sales_team_dashboard_tests.js
+++ /dev/null
@@ -1,173 +0,0 @@
-odoo.define('crm.dashboard_tests', function (require) {
-"use strict";
-
-// this file is no longer loaded in the test suite, so i guess we can remove it
-
-var testUtils = require('web.test_utils');
-var view_registry = require('web.view_registry');
-
-var createView = testUtils.createView;
-
-QUnit.module('CRM Sales Team Dashboard', {
- beforeEach: function () {
- this.data = {
- partner: {
- fields: {
- foo: {string: "Foo", type: "char"},
- },
- records: [
- {id: 1, foo: "yop"},
- {id: 2, foo: "blip"},
- {id: 3, foo: "gnap"},
- {id: 4, foo: "blip"},
- ]
- },
- };
- this.dashboard_data = {
- nb_opportunities: 6,
- currency_id: 3,
- won: {this_month: 0, last_month: 0, target: 0},
- done: {this_month: 0, last_month: 0, target: 0},
- activity: {next_7_days: 3, today: 1, overdue: 1},
- closing: {next_7_days: 1, today: 0, overdue: 0},
- meeting: {next_7_days: 1, today: 0},
- invoiced: {this_month: 0, last_month: 0, target: 0}
- };
- }
-});
-
-QUnit.test('dashboard basic rendering', function (assert) {
- assert.expect(2);
-
- var dashboard_data = this.dashboard_data;
- var kanban = createView({
- View: view_registry.get('sales_team_dashboard'),
- model: 'partner',
- data: this.data,
- arch: '
A help message
', - }, - }, - }); - - assert.containsOnce(kanban, 'div.o_sales_dashboard', - "should render the dashboard"); - assert.strictEqual(kanban.$('.o_view_nocontent:contains(A help message)').length, 1, - "should correctly render the nocontent helper"); - - kanban.destroy(); -}); - -});