diff --git a/addons/crm/data/crm_data.xml b/addons/crm/data/crm_data.xml index ddfb2fe40ae..5f1bfe35f86 100644 --- a/addons/crm/data/crm_data.xml +++ b/addons/crm/data/crm_data.xml @@ -5,7 +5,7 @@ True True sales - pipeline + crm.opportunity.report diff --git a/addons/crm/data/crm_demo.xml b/addons/crm/data/crm_demo.xml index a006c5df216..2b9aed9a324 100644 --- a/addons/crm/data/crm_demo.xml +++ b/addons/crm/data/crm_demo.xml @@ -11,7 +11,7 @@ True - pipeline + crm.opportunity.report diff --git a/addons/crm/models/crm_team.py b/addons/crm/models/crm_team.py index b16efe51e0a..aa6ec04747f 100644 --- a/addons/crm/models/crm_team.py +++ b/addons/crm/models/crm_team.py @@ -24,7 +24,7 @@ class Team(models.Model): opportunities_amount = fields.Integer( compute='_compute_opportunities', string='Amount of quotations to invoice', readonly=True) - dashboard_graph_model = fields.Selection(selection_add=[('pipeline', 'Pipeline')]) + dashboard_graph_model = fields.Selection(selection_add=[('crm.opportunity.report', 'Pipeline')]) dashboard_graph_period_pipeline = fields.Selection([ ('week', 'Within a Week'), ('month', 'Within a Month'), @@ -66,7 +66,7 @@ class Team(models.Model): channel.dashboard_graph_period_pipeline = channel.dashboard_graph_period def _inverse_dashboard_graph_period_pipeline(self): - for channel in self.filtered(lambda ch: ch.dashboard_graph_model == 'pipeline'): + for channel in self.filtered(lambda ch: ch.dashboard_graph_model == 'crm.opportunity.report'): channel.dashboard_graph_period = channel.dashboard_graph_period_pipeline def get_alias_model_name(self, vals): @@ -92,7 +92,7 @@ class Team(models.Model): if self.team_type == 'sales': self.use_opportunities = True self.use_leads = lambda self: self.user_has_groups('crm.group_use_lead') - self.dashboard_graph_model = 'pipeline' + self.dashboard_graph_model = 'crm.opportunity.report' else: self.use_opportunities = False self.use_leads = False @@ -100,7 +100,7 @@ class Team(models.Model): @api.onchange('dashboard_graph_model') def _onchange_dashboard_graph_model(self): - if self.dashboard_graph_model == 'pipeline': + if self.dashboard_graph_model == 'crm.opportunity.report': self.dashboard_graph_period_pipeline = self.dashboard_graph_period self.dashboard_graph_group_pipeline = self.dashboard_graph_group else: @@ -117,7 +117,7 @@ class Team(models.Model): @api.constrains('dashboard_graph_model', 'use_opportunities') def _check_graph_model(self): - if not self.use_opportunities and self.dashboard_graph_model == 'pipeline': + if not self.use_opportunities and self.dashboard_graph_model == 'crm.opportunity.report': raise ValidationError(_("Dashboard graph content cannot be Pipeline if the sales channel doesn't use it. (Pipeline is unchecked.)")) @api.model @@ -181,7 +181,7 @@ class Team(models.Model): def _graph_get_dates(self, today): """ return a coherent start and end date for the dashboard graph according to the graph settings. """ - if self.dashboard_graph_model == 'pipeline': + if self.dashboard_graph_model == 'crm.opportunity.report': if self.dashboard_graph_group == 'month': start_date = today.replace(day=1) elif self.dashboard_graph_group == 'week': @@ -210,7 +210,7 @@ class Team(models.Model): def _get_graph(self): graph_datas = super(Team, self)._get_graph() - if self.dashboard_graph_model == 'pipeline' and self.dashboard_graph_group_pipeline == 'stage': + 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_data = {d['id']: {'name': d['name'], 'sequence': d['sequence']} for d in stage_data} graph_datas[0]['values'] = sorted(graph_datas[0]['values'], key=lambda el: stage_data[el['label']]['sequence']) @@ -219,26 +219,21 @@ class Team(models.Model): return graph_datas def _graph_date_column(self): - if self.dashboard_graph_model == 'pipeline': + if self.dashboard_graph_model == 'crm.opportunity.report': return 'date_deadline' return super(Team, self)._graph_date_column() def _graph_x_query(self): - if self.dashboard_graph_model == 'pipeline' and self.dashboard_graph_group_pipeline == 'stage': + if self.dashboard_graph_model == 'crm.opportunity.report' and self.dashboard_graph_group_pipeline == 'stage': return 'stage_id' return super(Team, self)._graph_x_query() def _graph_y_query(self): - if self.dashboard_graph_model == 'pipeline': + if self.dashboard_graph_model == 'crm.opportunity.report': return 'SUM(expected_revenue)' return super(Team, self)._graph_y_query() - def _graph_sql_table(self): - if self.dashboard_graph_model == 'pipeline': - return 'crm_opportunity_report' - return super(Team, self)._graph_sql_table() - def _graph_title_and_key(self): - if self.dashboard_graph_model == 'pipeline': + if self.dashboard_graph_model == 'crm.opportunity.report': return ['', _('Expected Revenue')] # no more title return super(Team, self)._graph_title_and_key() diff --git a/addons/crm/views/crm_team_views.xml b/addons/crm/views/crm_team_views.xml index 94320c9c0e8..5dd284cf13e 100644 --- a/addons/crm/views/crm_team_views.xml +++ b/addons/crm/views/crm_team_views.xml @@ -109,16 +109,16 @@ attrs="{'invisible': [('use_leads', '=', False), ('use_opportunities', '=', False)]}"/> - {'invisible': [('dashboard_graph_model', '=', 'pipeline')]} + {'invisible': [('dashboard_graph_model', '=', 'crm.opportunity.report')]} - + - {'invisible': [('dashboard_graph_model', '=', 'pipeline')]} + {'invisible': [('dashboard_graph_model', '=', 'crm.opportunity.report')]} - + diff --git a/addons/pos_sale/data/pos_sale_data.xml b/addons/pos_sale/data/pos_sale_data.xml index 517833c75c7..08ff06db59d 100644 --- a/addons/pos_sale/data/pos_sale_data.xml +++ b/addons/pos_sale/data/pos_sale_data.xml @@ -4,7 +4,7 @@ Point of Sale - sales + sale.report diff --git a/addons/pos_sale/views/sales_team_views.xml b/addons/pos_sale/views/sales_team_views.xml index 13f79a22e16..e878ddcfad6 100644 --- a/addons/pos_sale/views/sales_team_views.xml +++ b/addons/pos_sale/views/sales_team_views.xml @@ -9,7 +9,7 @@ {'readonly': [('team_type', 'in', ['pos', 'ebay'])]} - {'invisible': ['|', ('dashboard_graph_model', '=', 'pipeline'), ('team_type', '=', 'pos')]} + {'invisible': ['|', ('dashboard_graph_model', '=', 'crm.opportunity.report'), ('team_type', '=', 'pos')]} diff --git a/addons/sale/data/sale_data.xml b/addons/sale/data/sale_data.xml index 96e231603c6..99eaf6256e6 100644 --- a/addons/sale/data/sale_data.xml +++ b/addons/sale/data/sale_data.xml @@ -10,7 +10,7 @@ - sales + sale.report diff --git a/addons/sale/data/sale_demo.xml b/addons/sale/data/sale_demo.xml index f4885f2f3d8..ec2212457d7 100644 --- a/addons/sale/data/sale_demo.xml +++ b/addons/sale/data/sale_demo.xml @@ -14,7 +14,7 @@ 40000 - sales + sale.report diff --git a/addons/sale/models/sales_team.py b/addons/sale/models/sales_team.py index 0cf551bd9b0..da1bda0a98b 100644 --- a/addons/sale/models/sales_team.py +++ b/addons/sale/models/sales_team.py @@ -32,8 +32,8 @@ class CrmTeam(models.Model): compute='_compute_sales_to_invoice', string='Number of sales to invoice', readonly=True) dashboard_graph_model = fields.Selection(selection_add=[ - ('sales', 'Sales'), - ('invoices', 'Invoices'), + ('sale.report', 'Sales'), + ('account.invoice.report', 'Invoices'), ]) def _compute_quotations_to_invoice(self): @@ -69,37 +69,30 @@ class CrmTeam(models.Model): self.browse(datum['team_id'][0]).invoiced = datum['amount_untaxed_signed'] def _graph_date_column(self): - if self.dashboard_graph_model == 'sales': + if self.dashboard_graph_model == 'sale.report': return 'confirmation_date' - elif self.dashboard_graph_model == 'invoices': + elif self.dashboard_graph_model == 'account.invoice.report': return 'date' return super(CrmTeam, self)._graph_date_column() def _graph_y_query(self): - if self.dashboard_graph_model == 'sales': + if self.dashboard_graph_model == 'sale.report': return 'SUM(price_subtotal)' - elif self.dashboard_graph_model == 'invoices': + elif self.dashboard_graph_model == 'account.invoice.report': return 'SUM(price_total)' return super(CrmTeam, self)._graph_y_query() - def _graph_sql_table(self): - if self.dashboard_graph_model == 'sales': - return 'sale_report' - elif self.dashboard_graph_model == 'invoices': - return 'account_invoice_report' - return super(CrmTeam, self)._graph_sql_table() - def _extra_sql_conditions(self): - if self.dashboard_graph_model == 'sales': + if self.dashboard_graph_model == 'sale.report': return "AND state in ('sale', 'done')" - elif self.dashboard_graph_model == 'invoices': + elif self.dashboard_graph_model == 'account.invoice.report': return "AND state in ('open', 'paid')" return super(CrmTeam, self)._extra_sql_conditions() def _graph_title_and_key(self): - if self.dashboard_graph_model == 'sales': + if self.dashboard_graph_model == 'sale.report': return ['', _('Untaxed Total')] # no more title - elif self.dashboard_graph_model == 'invoices': + elif self.dashboard_graph_model == 'account.invoice.report': return ['', _('Untaxed Total')] return super(CrmTeam, self)._graph_title_and_key() @@ -125,13 +118,13 @@ class CrmTeam(models.Model): if self.team_type == 'sales': self.use_quotations = True self.use_invoices = True - # do not override dashboard_graph_model 'pipeline' if crm is installed + # do not override dashboard_graph_model 'crm.opportunity.report' if crm is installed if not self.dashboard_graph_model: - self.dashboard_graph_model = 'sales' + self.dashboard_graph_model = 'sale.report' else: self.use_quotations = False self.use_invoices = False - self.dashboard_graph_model = 'sales' + self.dashboard_graph_model = 'sale.report' return super(CrmTeam, self)._onchange_team_type() @api.multi diff --git a/addons/sales_team/models/crm_team.py b/addons/sales_team/models/crm_team.py index 131ff1fd745..b02789c50f7 100644 --- a/addons/sales_team/models/crm_team.py +++ b/addons/sales_team/models/crm_team.py @@ -123,9 +123,6 @@ class CrmTeam(models.Model): def _graph_y_query(self): raise UserError(_('Undefined graph model for Sales Channel: %s') % self.name) - def _graph_sql_table(self): - raise UserError(_('Undefined graph model for Sales Channel: %s') % self.name) - def _extra_sql_conditions(self): return '' diff --git a/addons/website_sale/data/data.xml b/addons/website_sale/data/data.xml index 0ee5e9d4e28..910a5f95cfd 100644 --- a/addons/website_sale/data/data.xml +++ b/addons/website_sale/data/data.xml @@ -29,7 +29,7 @@ - sales + sale.report week