diff options
| author | qmo-odoo <qmo@odoo.com> | 2018-10-16 08:43:33 +0000 |
|---|---|---|
| committer | qmo-odoo <qmo@odoo.com> | 2018-12-05 15:32:53 +0000 |
| commit | 1da63f0ab0fb4212bee46f960c6bbe8ca9251cac (patch) | |
| tree | f324d0acc78a8c0f8c14a90edd303539399f71d5 /addons/sale_crm | |
| parent | e1f9499d2672fb0a346f8ac74552f038f5204a64 (diff) | |
[IMP] salesteam: Simplify sales team config and improved team dashboard
Reason:
*Sales team configuration is too complex with fields you
don't understand and that bring no added value
*Remove the team type, every team should be able to handle
a POS or a website for example
Contains:
*Removal of the team_type, use_quotations, use_leads fields
*Removal of the graph configuration fields
*Adapting the filters that were based on the team_type
*Clear distinction between the team dashboard behavior in crm
from the one in sales
*Cleansing of now dead code due to the removal of the previously
mentionned fields
Task: #1830105
Enterprise PR: #3006
Closes: #28063
Diffstat (limited to 'addons/sale_crm')
| -rw-r--r-- | addons/sale_crm/__init__.py | 7 | ||||
| -rw-r--r-- | addons/sale_crm/__manifest__.py | 2 | ||||
| -rw-r--r-- | addons/sale_crm/models/crm_team.py | 36 | ||||
| -rw-r--r-- | addons/sale_crm/views/crm_team_views.xml | 23 |
4 files changed, 66 insertions, 2 deletions
diff --git a/addons/sale_crm/__init__.py b/addons/sale_crm/__init__.py index dc5e6b693d1..e3e519761b8 100644 --- a/addons/sale_crm/__init__.py +++ b/addons/sale_crm/__init__.py @@ -2,3 +2,10 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. from . import models + +from odoo import api, SUPERUSER_ID + +def uninstall_hook(cr, registry): + env = api.Environment(cr, SUPERUSER_ID, {}) + teams = env['crm.team'].search([('use_opportunities', '=', False)]) + teams.write({'use_opportunities': True})
\ No newline at end of file diff --git a/addons/sale_crm/__manifest__.py b/addons/sale_crm/__manifest__.py index 4fb6af3d937..9620ea428e7 100644 --- a/addons/sale_crm/__manifest__.py +++ b/addons/sale_crm/__manifest__.py @@ -22,6 +22,8 @@ modules. 'views/partner_views.xml', 'views/sale_order_views.xml', 'views/crm_lead_views.xml', + 'views/crm_team_views.xml' ], 'auto_install': True, + 'uninstall_hook': 'uninstall_hook' } diff --git a/addons/sale_crm/models/crm_team.py b/addons/sale_crm/models/crm_team.py index b7e91e1b697..183f6cc03a2 100644 --- a/addons/sale_crm/models/crm_team.py +++ b/addons/sale_crm/models/crm_team.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from odoo import models, _ +from odoo import models,fields, api, _ class CrmTeam(models.Model): @@ -9,4 +9,36 @@ class CrmTeam(models.Model): def _compute_dashboard_button_name(self): super(CrmTeam, self)._compute_dashboard_button_name() - self.filtered(lambda team: team.use_opportunities and team.team_type in ('sales', 'website')).update({'dashboard_button_name': _("Pipeline")}) + teams_with_opp = self.filtered(lambda team: team.use_opportunities) + if self._context.get('in_sales_app'): + teams_with_opp.update({'dashboard_button_name': _("Sales Analysis")}) + + def action_primary_channel_button(self): + if self._context.get('in_sales_app') and self.use_opportunities: + return self.env.ref('sale.action_order_report_so_salesteam').read()[0] + return super(CrmTeam,self).action_primary_channel_button() + + def _graph_get_model(self): + if self.use_opportunities and self._context.get('in_sales_app') : + return 'sale.report' + return super(CrmTeam,self)._graph_get_model() + + def _graph_date_column(self): + if self.use_opportunities and self._context.get('in_sales_app'): + return 'confirmation_date' + return super(CrmTeam,self)._graph_date_column() + + def _graph_y_query(self): + if self.use_opportunities and self._context.get('in_sales_app'): + return 'SUM(price_subtotal)' + return super(CrmTeam,self)._graph_y_query() + + def _graph_title_and_key(self): + if self.use_opportunities and self._context.get('in_sales_app'): + return ['', _('Sales: Untaxed Total')] + return super(CrmTeam,self)._graph_title_and_key() + + def _extra_sql_conditions(self): + if self.use_opportunities and self._context.get('in_sales_app'): + return "AND state in ('sale', 'done', 'pos_done')" + return super(CrmTeam,self)._extra_sql_conditions() diff --git a/addons/sale_crm/views/crm_team_views.xml b/addons/sale_crm/views/crm_team_views.xml new file mode 100644 index 00000000000..7cd6d72129c --- /dev/null +++ b/addons/sale_crm/views/crm_team_views.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="utf-8"?> +<odoo> + <record id="crm_team_salesteams_view_form_in_sale_crm" model="ir.ui.view"> + <field name="name">crm.team.form</field> + <field name="model">crm.team</field> + <field name="inherit_id" ref="crm.sales_team_form_view_in_crm"/> + <field name="arch" type="xml"> + <data> + <xpath expr="//div[@name='opportunities']" position="attributes"> + <attribute name="invisible" value="0"/> + </xpath> + </data> + </field> + </record> + + <record id="sales_team.crm_team_salesteams_act" model="ir.actions.act_window"> + <field name="context">{'in_sales_app': True}</field> + </record> + + <record id="sales_team.crm_team_salesteams_pipelines_act" model="ir.actions.act_window"> + <field name="domain">[('use_opportunities', '=', True)]</field> + </record> +</odoo> |
