diff options
| author | dut-odoo <dut@odoo.com> | 2017-01-23 10:56:49 +0530 |
|---|---|---|
| committer | Denis Vermylen <dve@odoo.com> | 2017-04-21 18:37:55 +0200 |
| commit | 48e843aa8d906d1dc9e2d06e8a6d4e00cab45c59 (patch) | |
| tree | 8181a38332d5ca92f202779e863000a05293bc9b /addons | |
| parent | 1face40a5707171713dce576cd77133a300e89f6 (diff) | |
[IMP] sales_team: improve sale channel settings
Current sales channel configuration for graphs is complicated for users.
This commit attempts to simplify the form view by renaming labels on
selections depending on the chosen graph model.
It also adds the option to group by stage for the pipeline graph and
hides the team members for the POS and eBay sales channel.
- swap `groupby` with `period`
- for `sale` and `invoice` graphs:
- rename label: `period` -> `scale`
- rename graph periods' selection items: `This Month/ This Week/ This Year` -> `Last Month/ Last Week/ Last Year`
- for `pipeline` graph:
- rename label: `period` -> `expected to close`
- rename graph periods' selection items: `This Month/ This Week/ This Year` -> `Within a Month/ Within a Week/ Within a Year`
- rename graph groupbys: `Day/Week/Month` -> `Expected Closing Day/ Expected Closing Week/ Expected Closing Month`
- add new graph groupby: `Stage`
- remove lead management fields for ebay and pos channels
- hide `Assignation` page and `Domain`, `Assigned Leads Count` and `Minimum Score` fields
- in dashboard page, make content field readonly
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/crm/models/crm_team.py | 53 | ||||
| -rw-r--r-- | addons/crm/views/crm_team_views.xml | 12 | ||||
| -rw-r--r-- | addons/pos_sale/views/sales_team_views.xml | 4 | ||||
| -rw-r--r-- | addons/sales_team/models/crm_team.py | 8 | ||||
| -rw-r--r-- | addons/sales_team/views/crm_team_views.xml | 6 |
5 files changed, 74 insertions, 9 deletions
diff --git a/addons/crm/models/crm_team.py b/addons/crm/models/crm_team.py index 9480eaa150d..b16efe51e0a 100644 --- a/addons/crm/models/crm_team.py +++ b/addons/crm/models/crm_team.py @@ -25,6 +25,19 @@ class Team(models.Model): compute='_compute_opportunities', string='Amount of quotations to invoice', readonly=True) dashboard_graph_model = fields.Selection(selection_add=[('pipeline', 'Pipeline')]) + dashboard_graph_period_pipeline = fields.Selection([ + ('week', 'Within a Week'), + ('month', 'Within a Month'), + ('year', 'Within a Year'), + ], string='Expected to Close', help="The time period this channel's dashboard graph will consider.", + compute="_compute_dashboard_graph_period_pipeline", inverse="_inverse_dashboard_graph_period_pipeline") + dashboard_graph_group_pipeline = fields.Selection([ + ('day', 'Expected Closing Day'), + ('week', 'Expected Closing Week'), + ('month', 'Expected Closing Month'), + ('user', 'Salesperson'), + ('stage', 'Stage'), + ], string='Group by', default='day', help="How this channel's dashboard graph will group the results.") def _compute_unassigned_leads_count(self): leads_data = self.env['crm.lead'].read_group([ @@ -48,6 +61,14 @@ class Team(models.Model): team.opportunities_count = counts.get(team.id, 0) team.opportunities_amount = amounts.get(team.id, 0) + def _compute_dashboard_graph_period_pipeline(self): + for channel in self: + 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'): + channel.dashboard_graph_period = channel.dashboard_graph_period_pipeline + def get_alias_model_name(self, vals): return 'crm.lead' @@ -77,6 +98,23 @@ class Team(models.Model): self.use_leads = False return super(Team, self)._onchange_team_type() + @api.onchange('dashboard_graph_model') + def _onchange_dashboard_graph_model(self): + if self.dashboard_graph_model == 'pipeline': + self.dashboard_graph_period_pipeline = self.dashboard_graph_period + self.dashboard_graph_group_pipeline = self.dashboard_graph_group + else: + self.dashboard_graph_period = self.dashboard_graph_period_pipeline + if not self.dashboard_graph_group: + self.dashboard_graph_group = self._fields['dashboard_graph_group'].default(self) + + @api.onchange('dashboard_graph_group_pipeline') + def _onchange_dashboard_graph_group_pipeline(self): + if self.dashboard_graph_group_pipeline == 'stage': + self.dashboard_graph_group = False + else: + self.dashboard_graph_group = self.dashboard_graph_group_pipeline + @api.constrains('dashboard_graph_model', 'use_opportunities') def _check_graph_model(self): if not self.use_opportunities and self.dashboard_graph_model == 'pipeline': @@ -170,11 +208,26 @@ class Team(models.Model): return [start_date, end_date] return super(Team, self)._graph_get_dates(today) + def _get_graph(self): + graph_datas = super(Team, self)._get_graph() + if self.dashboard_graph_model == 'pipeline' 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']) + for gdata in graph_datas[0]['values']: + gdata['label'] = stage_data[gdata['label']]['name'] + return graph_datas + def _graph_date_column(self): if self.dashboard_graph_model == 'pipeline': 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': + return 'stage_id' + return super(Team, self)._graph_x_query() + def _graph_y_query(self): if self.dashboard_graph_model == 'pipeline': return 'SUM(expected_revenue)' diff --git a/addons/crm/views/crm_team_views.xml b/addons/crm/views/crm_team_views.xml index 23698ecc36c..94320c9c0e8 100644 --- a/addons/crm/views/crm_team_views.xml +++ b/addons/crm/views/crm_team_views.xml @@ -108,6 +108,18 @@ string="Accept Emails From" attrs="{'invisible': [('use_leads', '=', False), ('use_opportunities', '=', False)]}"/> </xpath> + <field name="dashboard_graph_period" position="attributes"> + <attribute name="attrs">{'invisible': [('dashboard_graph_model', '=', 'pipeline')]}</attribute> + </field> + <field name="dashboard_graph_period" position="after"> + <field name="dashboard_graph_period_pipeline" attrs="{'invisible': [('dashboard_graph_model', '!=', 'pipeline')]}"/> + </field> + <field name="dashboard_graph_group" position="attributes"> + <attribute name="attrs">{'invisible': [('dashboard_graph_model', '=', 'pipeline')]}</attribute> + </field> + <field name="dashboard_graph_group" position="after"> + <field name="dashboard_graph_group_pipeline" attrs="{'invisible': [('dashboard_graph_model', '!=', 'pipeline')]}"/> + </field> </field> </record> diff --git a/addons/pos_sale/views/sales_team_views.xml b/addons/pos_sale/views/sales_team_views.xml index 0ecb5c08140..13f79a22e16 100644 --- a/addons/pos_sale/views/sales_team_views.xml +++ b/addons/pos_sale/views/sales_team_views.xml @@ -6,10 +6,10 @@ <field name="inherit_id" ref="sales_team.crm_team_view_form"/> <field name="arch" type="xml"> <xpath expr="//field[@name='dashboard_graph_model']" position="attributes"> - <attribute name="attrs">{'invisible': [('team_type', '=', 'pos')]}</attribute> + <attribute name="attrs">{'readonly': [('team_type', 'in', ['pos', 'ebay'])]}</attribute> </xpath> <xpath expr="//field[@name='dashboard_graph_group']" position="attributes"> - <attribute name="attrs">{'invisible': [('team_type', '=', 'pos')]}</attribute> + <attribute name="attrs">{'invisible': ['|', ('dashboard_graph_model', '=', 'pipeline'), ('team_type', '=', 'pos')]}</attribute> </xpath> <xpath expr="//field[@name='dashboard_graph_group']" position="after"> <field name="dashboard_graph_group_pos" attrs="{'invisible': [('team_type', '!=', 'pos')]}"/> diff --git a/addons/sales_team/models/crm_team.py b/addons/sales_team/models/crm_team.py index a085622fc47..131ff1fd745 100644 --- a/addons/sales_team/models/crm_team.py +++ b/addons/sales_team/models/crm_team.py @@ -65,10 +65,10 @@ class CrmTeam(models.Model): ('user', 'Salesperson'), ], string='Group by', default='day', help="How this channel's dashboard graph will group the results.") dashboard_graph_period = fields.Selection([ - ('week', 'This Week'), - ('month', 'This Month'), - ('year', 'This Year'), - ], string='Period', default='month', help="The time period this channel's dashboard graph will consider.") + ('week', 'Last Week'), + ('month', 'Last Month'), + ('year', 'Last Year'), + ], string='Scale', default='month', help="The time period this channel's dashboard graph will consider.") @api.depends('dashboard_graph_group', 'dashboard_graph_model', 'dashboard_graph_period') def _compute_dashboard_graph(self): diff --git a/addons/sales_team/views/crm_team_views.xml b/addons/sales_team/views/crm_team_views.xml index bd2b9f552e0..73e34493902 100644 --- a/addons/sales_team/views/crm_team_views.xml +++ b/addons/sales_team/views/crm_team_views.xml @@ -94,7 +94,7 @@ </group> </group> <notebook> - <page name="members" string="Team Members"> + <page name="members" string="Team Members" attrs="{'invisible': [('team_type', 'in', ['pos', 'ebay'])]}"> <field name="member_ids" options="{'not_delete': True}"> <kanban quick_create="false" create="true" delete="true"> <field name="id"/> @@ -117,9 +117,9 @@ </page> <page string="Dashboard" name="dashboard"> <group string="Graph" name="graph"> - <field name="dashboard_graph_model"/> - <field name="dashboard_graph_group"/> + <field name="dashboard_graph_model" attrs="{'readonly': [('team_type', 'in', ['pos', 'ebay'])]}"/> <field name="dashboard_graph_period"/> + <field name="dashboard_graph_group"/> </group> </page> </notebook> |
