[FIX] crm: fix behavior of 'Emails' checkbox in settings
Currently there are several issues with this configuration box * default_<field> does not generate automatically ir.values anymore. Defining default_model does not work since it is not linked to an existing <field> in current model sale.config.settings. Checkbox value is therefore not saved and lost at reload; * box label is not clear as user may understand unchecking it drops all aliases or email support. This is not the case as it is only used to define an alias creating unassigned leads. This is a rare use case where leads assignation is done manually; * checking / unchecking the 'Emails' box does not have any effect on default info alias. This is counter-intuitive as user asks to remove the feature but it still works in background; This commit fixes those issues by * correctly setting the checkbox value in an ir.config_parameter so that it is not lost anymore at reload; * inactivating info alias by default; * adding onchanges so that values are reset when unchecking checkboxes; * updating string and displayed label and helps for the 'Emails' section; * putting that Emails checkbox in advanced mode as it is a rare use case;
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
|
||||
<!--default alias for leads-->
|
||||
<record id="mail_alias_lead_info" model="mail.alias">
|
||||
<field name="alias_name">info</field>
|
||||
<field name="alias_name"></field>
|
||||
<field name="alias_model_id" ref="model_crm_lead"/>
|
||||
<field name="alias_user_id" ref="base.user_root"/>
|
||||
<field name="alias_parent_model_id" ref="model_crm_team"/>
|
||||
|
||||
@@ -11,7 +11,8 @@ class CRMSettings(models.TransientModel):
|
||||
help="Odoo will generate an email alias based on the sales channel name")
|
||||
alias_prefix = fields.Char('Default Alias Name for Leads')
|
||||
alias_domain = fields.Char('Alias Domain', default=lambda self: self.env["ir.config_parameter"].sudo().get_param("mail.catchall.domain"))
|
||||
default_generate_lead_from_alias = fields.Boolean()
|
||||
# TDE TODO: as it is not linked to ir.values anymore, it should be renamed, but not in stable
|
||||
default_generate_lead_from_alias = fields.Boolean('Manual Assignation of Emails')
|
||||
group_use_lead = fields.Boolean(string="Leads", implied_group='crm.group_use_lead')
|
||||
module_crm_voip = fields.Boolean("Asterisk (VoIP)")
|
||||
|
||||
@@ -40,6 +41,26 @@ class CRMSettings(models.TransientModel):
|
||||
IrValues = IrValues.sudo()
|
||||
IrValues.set_default('sale.config.settings', 'generate_sales_team_alias', self.generate_sales_team_alias)
|
||||
|
||||
@api.model
|
||||
def get_default_default_generate_lead_from_alias(self, fields):
|
||||
return {
|
||||
'default_generate_lead_from_alias': self.env['ir.config_parameter'].sudo().get_param('sale_config_settings.default_generate_lead_from_alias')
|
||||
}
|
||||
|
||||
@api.multi
|
||||
def set_default_default_generate_lead_from_alias(self):
|
||||
self.env['ir.config_parameter'].sudo().set_param('sale_config_settings.default_generate_lead_from_alias', self.default_generate_lead_from_alias)
|
||||
|
||||
@api.onchange('group_use_lead')
|
||||
def _onchange_group_use_lead(self):
|
||||
""" Reset alias / leads configuration if leads are not used """
|
||||
if not self.group_use_lead:
|
||||
self.default_generate_lead_from_alias = False
|
||||
|
||||
@api.onchange('default_generate_lead_from_alias')
|
||||
def _onchange_default_generate_lead_from_alias(self):
|
||||
self.alias_prefix = 'info' if self.default_generate_lead_from_alias else False
|
||||
|
||||
@api.model
|
||||
def get_default_alias_prefix(self, fields):
|
||||
alias = self._find_default_lead_alias_id()
|
||||
|
||||
@@ -20,19 +20,24 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-12 col-md-6 o_setting_box" id="crm_lead" attrs="{'invisible': [('group_use_lead','=',False)]}" title="Emails received to that address generate new leads not assigned to any sales channel yet. This can be made when converting them into opportunities. Incoming emails can be automatically assigned to specific sales channels. To do so, set an email alias on the sales channel.">
|
||||
<div class="col-xs-12 col-md-6 o_setting_box" id="crm_lead"
|
||||
attrs="{'invisible': [('group_use_lead','=',False)]}"
|
||||
title="Emails received to that address generate new leads not assigned to any sales channel yet. This can be made when converting them into opportunities. Incoming emails can be automatically assigned to specific sales channels. To do so, set an email alias on the sales channel."
|
||||
groups="base.group_no_one">
|
||||
<div class="o_setting_left_pane">
|
||||
<field name="default_generate_lead_from_alias"/>
|
||||
</div>
|
||||
<div class="o_setting_right_pane">
|
||||
<label string="Emails"/>
|
||||
<label string="Manually Assignation of Incoming Emails"/>
|
||||
<div class="text-muted">
|
||||
Generate leads from incoming emails
|
||||
Generate unassigned leads from incoming emails. Leads coming from
|
||||
that email will be assigned manually.
|
||||
</div>
|
||||
<div class="content-group" attrs="{'invisible': [('default_generate_lead_from_alias','=',False)]}">
|
||||
<div class="mt16">
|
||||
<label string="Alias" class="o_light_label"/>
|
||||
<field name="alias_prefix" class="oe_inline"/>
|
||||
<field name="alias_prefix" class="oe_inline"
|
||||
attrs="{'required': [('default_generate_lead_from_alias', '=', True)]}"/>
|
||||
<span>@</span>
|
||||
<field name="alias_domain" readonly="1" class="oe_inline"/>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user