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/crm_lead.py b/addons/crm/models/crm_lead.py index 4d99cb879c5..b7100c4824a 100644 --- a/addons/crm/models/crm_lead.py +++ b/addons/crm/models/crm_lead.py @@ -1397,17 +1397,12 @@ class Lead(models.Model): through message_process. This override updates the document according to the email. """ - - # remove external users - if self.env.user.has_group('base.group_portal'): - self = self.with_context(default_user_id=False) - # remove default author when going through the mail gateway. Indeed we - # do not want to explicitly set user_id to False; however we do not - # want the gateway user to be responsible if no other responsible is - # found. - if self._uid == self.env.ref('base.user_root').id: - self = self.with_context(default_user_id=False) + # do not want to explicitly set an user as responsible. We prefer that + # assignment is done automatically (scoring) or manually. Otherwise it + # would always be either root (gateway user) either alias owner (through + # alias_user_id). It also allows to exclude portal / public users. + self = self.with_context(default_user_id=False) if custom_values is None: custom_values = {} diff --git a/addons/crm/models/res_config_settings.py b/addons/crm/models/res_config_settings.py index f01f8ea93c1..994c37bce9b 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,39 +58,15 @@ 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): + group_lead_before = self.env.ref('crm.group_use_lead') in self.env.user.groups_id 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()) + group_lead_after = self.env.ref('crm.group_use_lead') in self.env.user.groups_id + if group_lead_before != group_lead_after: + teams = self.env['crm.team'].search([]) + teams.filtered('use_opportunities').use_leads = group_lead_after + for team in teams: + team.alias_id.write(team._alias_get_creation_values()) # ACTIONS def action_reset_lead_probabilities(self): diff --git a/addons/crm/views/crm_team_views.xml b/addons/crm/views/crm_team_views.xml index 7eb900bca17..4ca2195f9d6 100644 --- a/addons/crm/views/crm_team_views.xml +++ b/addons/crm/views/crm_team_views.xml @@ -124,9 +124,10 @@
-
-
+ string="Email Alias" required="0" + attrs="{'invisible': [('alias_domain', '=', False)]}"/> +
+
@
-
-
- -
-
-
-

Lead Generation