[MERGE] forward port branch 9.0 up to 4aea19d9e8
This commit is contained in:
@@ -928,34 +928,36 @@ class Lead(FormatAddress, models.Model):
|
||||
'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.date_deadline:
|
||||
date_deadline = fields.Date.from_string(opp.date_deadline)
|
||||
if date_deadline == date.today():
|
||||
if date_deadline == today:
|
||||
result['closing']['today'] += 1
|
||||
if date.today() <= date_deadline <= date.today() + timedelta(days=7):
|
||||
if today <= date_deadline <= today + timedelta(days=7):
|
||||
result['closing']['next_7_days'] += 1
|
||||
if date_deadline < date.today() and not opp.date_closed:
|
||||
if date_deadline < today and not opp.date_closed:
|
||||
result['closing']['overdue'] += 1
|
||||
# Next activities
|
||||
if opp.next_activity_id and opp.date_action:
|
||||
date_action = fields.Date.from_string(opp.date_action)
|
||||
if date_action == date.today():
|
||||
if date_action == today:
|
||||
result['activity']['today'] += 1
|
||||
if date.today() <= date_action <= date.today() + timedelta(days=7):
|
||||
if today <= date_action <= today + timedelta(days=7):
|
||||
result['activity']['next_7_days'] += 1
|
||||
if date_action < date.today() and not opp.date_closed:
|
||||
if date_action < today and not opp.date_closed:
|
||||
result['activity']['overdue'] += 1
|
||||
# Won in Opportunities
|
||||
if opp.date_closed:
|
||||
date_closed = fields.Date.from_string(opp.date_closed)
|
||||
if date.today().replace(day=1) <= date_closed <= date.today():
|
||||
if today.replace(day=1) <= date_closed <= today:
|
||||
if opp.planned_revenue:
|
||||
result['won']['this_month'] += opp.planned_revenue
|
||||
elif date.today() + relativedelta(months=-1, day=1) <= date_closed < date.today().replace(day=1):
|
||||
elif today + relativedelta(months=-1, day=1) <= date_closed < today.replace(day=1):
|
||||
if opp.planned_revenue:
|
||||
result['won']['last_month'] += opp.planned_revenue
|
||||
|
||||
@@ -980,9 +982,9 @@ class Lead(FormatAddress, models.Model):
|
||||
for activity in activites_done:
|
||||
if activity['date']:
|
||||
date_act = fields.Date.from_string(activity['date'])
|
||||
if date.today().replace(day=1) <= date_act <= date.today():
|
||||
if today.replace(day=1) <= date_act <= today:
|
||||
result['done']['this_month'] += 1
|
||||
elif date.today() + relativedelta(months=-1, day=1) <= date_act < date.today().replace(day=1):
|
||||
elif today + relativedelta(months=-1, day=1) <= date_act < today.replace(day=1):
|
||||
result['done']['last_month'] += 1
|
||||
|
||||
# Meetings
|
||||
@@ -997,9 +999,9 @@ class Lead(FormatAddress, models.Model):
|
||||
for meeting in meetings:
|
||||
if meeting['start']:
|
||||
start = datetime.strptime(meeting['start'], tools.DEFAULT_SERVER_DATETIME_FORMAT).date()
|
||||
if start == date.today():
|
||||
if start == today:
|
||||
result['meeting']['today'] += 1
|
||||
if date.today() <= start <= date.today() + timedelta(days=7):
|
||||
if today <= start <= today + timedelta(days=7):
|
||||
result['meeting']['next_7_days'] += 1
|
||||
|
||||
result['done']['target'] = self.env.user.target_sales_done
|
||||
|
||||
@@ -8,7 +8,7 @@ SalesTeamDashboardView.include({
|
||||
|
||||
fetch_data: function() {
|
||||
return new Model('crm.lead')
|
||||
.call('retrieve_sales_dashboard', []);
|
||||
.call('retrieve_sales_dashboard', [], {context: this.session.user_context || {}});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from datetime import date
|
||||
from dateutil.relativedelta import relativedelta
|
||||
|
||||
from odoo import api, fields, models, _
|
||||
@@ -31,7 +30,7 @@ class CrmLead(models.Model):
|
||||
@api.model
|
||||
def retrieve_sales_dashboard(self):
|
||||
res = super(CrmLead, self).retrieve_sales_dashboard()
|
||||
date_today = date.today()
|
||||
date_today = fields.Date.from_string(fields.Date.context_today(self))
|
||||
|
||||
res['invoiced'] = {
|
||||
'this_month': 0,
|
||||
|
||||
Reference in New Issue
Block a user