From 0d2be38333d8fe5a4cbef4161ac92cac00e47eb1 Mon Sep 17 00:00:00 2001 From: qmo-odoo Date: Tue, 30 Jul 2019 11:29:52 +0000 Subject: [PATCH] [IMP] crm,sale,*: Improve UX This commit improves the ux in CRM by changing a few things: - Restore the use_leads and use_quotations fields along with their features as they were in 12.0. - Hide the email alias if use_upportunities and use_leads are unchecked. - Show a link to the general settings instead of the alias_domain if no alias_domain has been configured. - fixes the "unassigned lead(s)" link so that it redirects the user to the actually unassigned leads Task: #1962182 PR: #32372 --- addons/crm/data/crm_demo.xml | 4 + addons/crm/models/crm_team.py | 22 +++--- addons/crm/views/crm_lead_views.xml | 6 +- addons/crm/views/crm_team_views.xml | 73 +++++++++++-------- .../crm/views/res_config_settings_views.xml | 6 +- addons/sale/data/sale_demo.xml | 2 + addons/sale/models/sales_team.py | 5 +- addons/sale/views/sales_team_views.xml | 10 ++- addons/sale_crm/views/crm_team_views.xml | 5 +- addons/website_crm/models/crm_lead.py | 2 +- .../website_crm/models/res_config_settings.py | 2 +- .../tests/test_partner_assign.py | 1 + 12 files changed, 81 insertions(+), 57 deletions(-) diff --git a/addons/crm/data/crm_demo.xml b/addons/crm/data/crm_demo.xml index de433c3afeb..f5f0ed06bed 100644 --- a/addons/crm/data/crm_demo.xml +++ b/addons/crm/data/crm_demo.xml @@ -10,5 +10,9 @@ + + + True + diff --git a/addons/crm/models/crm_team.py b/addons/crm/models/crm_team.py index a1a0f42bd6f..189799a37de 100644 --- a/addons/crm/models/crm_team.py +++ b/addons/crm/models/crm_team.py @@ -12,8 +12,10 @@ class Team(models.Model): _name = 'crm.team' _inherit = ['mail.alias.mixin', 'crm.team'] _description = 'Sales Team' - use_opportunities = fields.Boolean('Manage a pipeline', default=True, help="Check this box to manage a presales process with opportunities.") - alias_id = fields.Many2one('mail.alias', string='Alias', ondelete="restrict", required=True, help="The email address associated with this channel. New emails received will automatically create new leads assigned to the channel.") + + use_leads = fields.Boolean('Leads', help="Check this box to filter and qualify incoming requests as leads before converting them into opportunities and assigning them to a salesperson.") + use_opportunities = fields.Boolean('Pipeline', default=True, help="Check this box to manage a presales process with opportunities.") + alias_id = fields.Many2one('mail.alias', string='Alias', ondelete="restrict", required=True, help="The email address associated with this channel. New emails received will automatically create new leads assigned to the channel.") unassigned_leads_count = fields.Integer( compute='_compute_unassigned_leads_count', @@ -76,10 +78,10 @@ class Team(models.Model): for team in self: team.overdue_opportunities_count = counts.get(team.id, 0) team.overdue_opportunities_amount = amounts.get(team.id, 0) - - @api.onchange('use_opportunities') - def _onchange_opportunities(self): - if not self.use_opportunities: + + @api.onchange('use_leads', 'use_opportunities') + def _onchange_use_leads_opportunities(self): + if not self.use_leads and not self.use_opportunities: self.alias_name = False def get_alias_model_name(self, vals): @@ -89,13 +91,13 @@ class Team(models.Model): has_group_use_lead = self.env.user.has_group('crm.group_use_lead') values = super(Team, self).get_alias_values() values['alias_defaults'] = defaults = safe_eval(self.alias_defaults or "{}") - defaults['type'] = 'lead' if has_group_use_lead else 'opportunity' + defaults['type'] = 'lead' if has_group_use_lead and self.use_leads else 'opportunity' defaults['team_id'] = self.id - return values + return values def write(self, vals): result = super(Team, self).write(vals) - if 'alias_defaults' in vals: + if 'use_leads' in vals or 'alias_defaults' in vals: for team in self: team.alias_id.write(team.get_alias_values()) return result @@ -130,7 +132,7 @@ class Team(models.Model): if self.use_opportunities: return self.env.ref('crm.crm_case_form_view_salesteams_opportunity').read()[0] return super(Team,self).action_primary_channel_button() - + def _graph_get_model(self): if self.use_opportunities: return 'crm.lead' diff --git a/addons/crm/views/crm_lead_views.xml b/addons/crm/views/crm_lead_views.xml index 75970269e0d..afd98c695ca 100644 --- a/addons/crm/views/crm_lead_views.xml +++ b/addons/crm/views/crm_lead_views.xml @@ -134,7 +134,7 @@ - + @@ -456,6 +456,8 @@ name="assigned_to_me" domain="[('user_id', '=', uid)]" help="Leads that are assigned to me"/> + @@ -624,7 +626,7 @@ - + diff --git a/addons/crm/views/crm_team_views.xml b/addons/crm/views/crm_team_views.xml index bee29801300..85fab9cba20 100644 --- a/addons/crm/views/crm_team_views.xml +++ b/addons/crm/views/crm_team_views.xml @@ -97,36 +97,42 @@ - crm.team.form.inherit - crm.team - - 12 - - -
+ crm.team.form.inherit + crm.team + + 12 + + +
+ + + + +
+
+ + +
+ @@ -173,6 +179,10 @@ + + [('use_opportunities', '=', True)] + + crm.team.kanban crm.team @@ -184,10 +194,11 @@ + -
+
 
@@ -195,7 +206,7 @@
- + Unassigned Lead Unassigned Leads @@ -229,7 +240,7 @@ -
+
Leads @@ -250,7 +261,7 @@ -
+
Leads diff --git a/addons/crm/views/res_config_settings_views.xml b/addons/crm/views/res_config_settings_views.xml index ed20f377978..18a31d5af09 100644 --- a/addons/crm/views/res_config_settings_views.xml +++ b/addons/crm/views/res_config_settings_views.xml @@ -30,14 +30,12 @@
-