summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorNicolas Lempereur <nle@odoo.com>2017-12-07 19:10:17 +0100
committerNicolas Lempereur <nle@odoo.com>2017-12-11 16:04:01 +0100
commitd0d9196da406baba37d634dd78ac0e12e83f754d (patch)
treeb039f669bed562a30ce003e1a148b8e3ee5baf9e /addons
parent35c4057422efd32318d08bbfaf5ba0ee1d17f11d (diff)
[FIX] crm: crm team graph error if stage deleted
When a stage on crm leads is removed, the leads appear in an "Undefined" column in a kanban view, but this was not handled when getting the "graph data" (eg. in version 11.0 for sales team graphs when grouping by stage in CRM > Reporting > Sales Channels). opw-784455 closes #21507
Diffstat (limited to 'addons')
-rw-r--r--addons/crm/models/crm_team.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/addons/crm/models/crm_team.py b/addons/crm/models/crm_team.py
index ca9421be935..2e9bfbcef8a 100644
--- a/addons/crm/models/crm_team.py
+++ b/addons/crm/models/crm_team.py
@@ -211,8 +211,11 @@ class Team(models.Model):
def _get_graph(self):
graph_datas = super(Team, self)._get_graph()
if self.dashboard_graph_model == 'crm.opportunity.report' and self.dashboard_graph_group_pipeline == 'stage':
- stage_data = self.env['crm.stage'].browse([d['label'] for d in graph_datas[0]['values']]).read(['sequence', 'name'])
+ stage_ids = [d['label'] for d in graph_datas[0]['values'] if d['label'] is not None]
+ stage_data = self.env['crm.stage'].browse(stage_ids).read(['sequence', 'name'])
stage_data = {d['id']: {'name': d['name'], 'sequence': d['sequence']} for d in stage_data}
+ # use "Undefined" stage for unset stage records
+ stage_data[None] = {'name': _('Undefined'), 'sequence': -1}
graph_datas[0]['values'] = sorted(graph_datas[0]['values'], key=lambda el: stage_data[el['label']]['sequence'])
for gdata in graph_datas[0]['values']:
gdata['label'] = stage_data[gdata['label']]['name']