From 1ee68e61191fe56743fb007d33be2e69cfaf9ac0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 10 Dec 2020 12:40:24 +0000 Subject: [PATCH] [REF] crm: remove global lead alias MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PURPOSE Remove the alias setting option because it is a weird and hackish way to proceed. We would prefer users to configure their alias through sales teams. Improve alias configuration on teams. RATIONALE "​Incoming Emails" option has many flaws * it creates collision when you try to set an alias that is already used and it is not easy to find them back; * it has no default value (no sales team, no type, ...) and works through the 'owner' field. This is set with the admin on activation of the feature which is not correct. The admin is potentially not a salesperson. If you set the field to blank, you get leads without team and without assigned responsible. * this alias is not team-bound which thus asks the question: in which team should the lead ever go? To the first team? Why? All this make it seem way healthier to handle this through the Sales Team. => By default, we'll already have one working with an alias. If users really want a global lead alias it can be setup manually through alias menu in configuration. Shortcut and default alias in crm are removed but feature is still doable if requested. SPECIFICATIONS Remove the s "Incoming emails" setting that allows to setup a global alias for leads / opportunities with a default value being 'contact'. Also remove related alias data as it has no use anymore. LINKS Task ID-2414079 Sort of follow-up of Task ID-2373095. COM PR odoo/odoo#63160 UPG PR odoo/upgrade#2017 --- addons/crm/__manifest__.py | 2 +- addons/crm/data/mail_data.xml | 8 ---- addons/crm/models/res_config_settings.py | 47 ------------------- .../crm/views/res_config_settings_views.xml | 26 ---------- 4 files changed, 1 insertion(+), 82 deletions(-) diff --git a/addons/crm/__manifest__.py b/addons/crm/__manifest__.py index e474ef3e83e..d74210125f3 100644 --- a/addons/crm/__manifest__.py +++ b/addons/crm/__manifest__.py @@ -3,7 +3,7 @@ { 'name': 'CRM', - 'version': '1.3', + 'version': '1.4', 'category': 'Sales/CRM', 'sequence': 15, 'summary': 'Track leads and close opportunities', diff --git a/addons/crm/data/mail_data.xml b/addons/crm/data/mail_data.xml index 9ad6c946d11..52f506f0503 100644 --- a/addons/crm/data/mail_data.xml +++ b/addons/crm/data/mail_data.xml @@ -1,14 +1,6 @@ - - - - - - - - Opportunity Created diff --git a/addons/crm/models/res_config_settings.py b/addons/crm/models/res_config_settings.py index f01f8ea93c1..bccf20a322e 100644 --- a/addons/crm/models/res_config_settings.py +++ b/addons/crm/models/res_config_settings.py @@ -7,12 +7,6 @@ from odoo import api, fields, models class ResConfigSettings(models.TransientModel): _inherit = 'res.config.settings' - crm_alias_prefix = fields.Char( - 'Default Alias Name for Leads', - compute="_compute_crm_alias_prefix" , readonly=False, store=True) - generate_lead_from_alias = fields.Boolean( - 'Manual Assignment of Emails', config_parameter='crm.generate_lead_from_alias', - compute="_compute_generate_lead_from_alias", readonly=False, store=True) group_use_lead = fields.Boolean(string="Leads", implied_group='crm.group_use_lead') group_use_recurring_revenues = fields.Boolean(string="Recurring Revenues", implied_group='crm.group_use_recurring_revenues') module_crm_iap_lead = fields.Boolean("Generate new leads based on their country, industries, size, etc.") @@ -29,18 +23,6 @@ class ResConfigSettings(models.TransientModel): predictive_lead_scoring_fields = fields.Many2many('crm.lead.scoring.frequency.field', string='Lead Scoring Frequency Fields', compute="_compute_pls_fields", inverse="_inverse_pls_fields_str") predictive_lead_scoring_fields_str = fields.Char(string='Lead Scoring Frequency Fields in String', config_parameter='crm.pls_fields') - def _find_default_lead_alias_id(self): - alias = self.env.ref('crm.mail_alias_lead_info', False) - if not alias: - alias = self.env['mail.alias'].search([ - ('alias_model_id.model', '=', 'crm.lead'), - ('alias_force_thread_id', '=', False), - ('alias_parent_model_id.model', '=', 'crm.team'), - ('alias_parent_thread_id', '=', False), - ('alias_defaults', '=', '{}') - ], limit=1) - return alias - @api.depends('predictive_lead_scoring_fields_str') def _compute_pls_fields(self): """ As config_parameters does not accept m2m field, @@ -76,37 +58,8 @@ class ResConfigSettings(models.TransientModel): if setting.predictive_lead_scoring_start_date: setting.predictive_lead_scoring_start_date_str = fields.Date.to_string(setting.predictive_lead_scoring_start_date) - @api.depends('group_use_lead') - def _compute_generate_lead_from_alias(self): - """ Reset alias / leads configuration if leads are not used """ - for setting in self.filtered(lambda r: not r.group_use_lead): - setting.generate_lead_from_alias = False - - @api.depends('generate_lead_from_alias') - def _compute_crm_alias_prefix(self): - for setting in self: - setting.crm_alias_prefix = (setting.crm_alias_prefix or 'contact') if setting.generate_lead_from_alias else False - - @api.model - def get_values(self): - res = super(ResConfigSettings, self).get_values() - alias = self._find_default_lead_alias_id() - res.update( - crm_alias_prefix=alias.alias_name if alias else False, - ) - return res - def set_values(self): super(ResConfigSettings, self).set_values() - alias = self._find_default_lead_alias_id() - if alias: - alias.write({'alias_name': self.crm_alias_prefix}) - else: - self.env['mail.alias'].create({ - 'alias_name': self.crm_alias_prefix, - 'alias_model_id': self.env['ir.model']._get('crm.lead').id, - 'alias_parent_model_id': self.env['ir.model']._get('crm.team').id, - }) for team in self.env['crm.team'].search([]): team.alias_id.write(team._alias_get_creation_values()) diff --git a/addons/crm/views/res_config_settings_views.xml b/addons/crm/views/res_config_settings_views.xml index 7d38c8846d2..d5a8a937bad 100644 --- a/addons/crm/views/res_config_settings_views.xml +++ b/addons/crm/views/res_config_settings_views.xml @@ -66,32 +66,6 @@ -
-
- -
-
-
-

Lead Generation