Skip to content

Commit

Permalink
[FIX] crm: bad computation of 'Won in opportunities'
Browse files Browse the repository at this point in the history
The filter on activity_date_deadline has been added during a fix, see
28c158c
It's incorrect for the computation of the 'Won in opportunities'
because it excludes opportunities not having activity_ids.

Furthermore, the way to compute the 'won' amount is not equals to the
filters when clicking on the button. Then, we need to keep only
opportunities standing in a kanban column having a probability of 100%.

opw-742489
  • Loading branch information
smetl authored and nim-odoo committed May 17, 2017
1 parent a6e2b39 commit 31b37b8
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions addons/crm/models/crm_lead.py
Original file line number Diff line number Diff line change
Expand Up @@ -896,29 +896,30 @@ def retrieve_sales_dashboard(self):
'nb_opportunities': 0,
}

opportunities = self.search([('type', '=', 'opportunity'), ('user_id', '=', self._uid), ('activity_date_deadline', '!=', False)])
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():
result['closing']['today'] += 1
if date.today() <= date_deadline <= date.today() + timedelta(days=7):
result['closing']['next_7_days'] += 1
if date_deadline < date.today():
result['closing']['overdue'] += 1
# Next activities
for activity in opp.activity_ids:
date_deadline = fields.Date.from_string(activity.date_deadline)
if date_deadline == date.today():
result['activity']['today'] += 1
if date.today() <= date_deadline <= date.today() + timedelta(days=7):
result['activity']['next_7_days'] += 1
if date_deadline < date.today():
result['activity']['overdue'] += 1
if opp.activity_date_deadline:
if opp.date_deadline:
date_deadline = fields.Date.from_string(opp.date_deadline)
if date_deadline == date.today():
result['closing']['today'] += 1
if date.today() <= date_deadline <= date.today() + timedelta(days=7):
result['closing']['next_7_days'] += 1
if date_deadline < date.today():
result['closing']['overdue'] += 1
# Next activities
for activity in opp.activity_ids:
date_deadline = fields.Date.from_string(activity.date_deadline)
if date_deadline == date.today():
result['activity']['today'] += 1
if date.today() <= date_deadline <= date.today() + timedelta(days=7):
result['activity']['next_7_days'] += 1
if date_deadline < date.today():
result['activity']['overdue'] += 1
# Won in Opportunities
if opp.date_closed:
if opp.date_closed and opp.stage_id.probability == 100:
date_closed = fields.Date.from_string(opp.date_closed)
if date.today().replace(day=1) <= date_closed <= date.today():
if opp.planned_revenue:
Expand Down

0 comments on commit 31b37b8

Please sign in to comment.