[REF] crm: improve team opt-out from lead automatic assignment
GLOBAL PURPOSE Ability to have salesmen belonging to several sales team is a core requirement of CRM. It is therefore moved from website_crm_score to crm along with cleaning and behavior improvement. Automatic lead assignment is also moved and cleaned. SPECIFICATIONS: TEAM OPT-OUT OF ASSIGN Allow teams to individually opt-out automatic assignment. If automatic assignment is activated one can make some team opt-out of automatic process. Manual assignment on team through an action button is possible even when opt-outed. Allow teams to individually opt-out automatic assignment. If automatic assignment is activated one can make some team opt-out of automatic process. Manual assignment on team through an action button is possible even when opt-outed. SPECIFICATIONS: RESTRICT ASSIGN TO OPPORTUNITIES ENABLED TEAMS Only teams with use_leads or use_oppotunities should be included in automatic assign. Indeed other teams like POS, website) do not handle opportunities or leads. Automatically assigning them leads makes no sense. LINKS Task ID-2086889 (main task) Task ID-2357969 (scoring migration task) Community PR odoo/odoo#48422 Enterprise PR odoo/enterprise#499 Upgrade PR odoo/upgrade#996
This commit is contained in:
@@ -29,6 +29,7 @@ class Team(models.Model):
|
||||
# assignment
|
||||
assignment_enabled = fields.Boolean('Lead Assign', compute='_compute_assignment_enabled')
|
||||
assignment_auto_enabled = fields.Boolean('Auto Assignment', compute='_compute_assignment_enabled')
|
||||
assignment_optout = fields.Boolean('Skip auto assignment')
|
||||
assignment_max = fields.Integer(
|
||||
'Lead Capacity', compute='_compute_assignment_max',
|
||||
help='Monthly leads for all salesmen belonging to the team')
|
||||
@@ -188,7 +189,10 @@ class Team(models.Model):
|
||||
elif assign_cron.interval_type == 'days':
|
||||
work_days = 2 * assign_cron.interval_number * 1
|
||||
work_days = 30 if work_days > 30 else work_days
|
||||
self.env['crm.team'].search([])._action_assign_leads(work_days=work_days)
|
||||
self.env['crm.team'].search([
|
||||
'&', '|', ('use_leads', '=', True), ('use_opportunities', '=', True),
|
||||
('assignment_optout', '=', False)
|
||||
])._action_assign_leads(work_days=work_days)
|
||||
return True
|
||||
|
||||
def action_assign_leads(self, work_days=2):
|
||||
|
||||
@@ -144,4 +144,4 @@ class ResConfigSettings(models.TransientModel):
|
||||
|
||||
def action_crm_assign_leads(self):
|
||||
self.ensure_one()
|
||||
return self.env['crm.team'].search([]).action_assign_leads()
|
||||
return self.env['crm.team'].search([('assignment_optout', '=', False)]).action_assign_leads()
|
||||
|
||||
@@ -112,7 +112,7 @@
|
||||
string="Assign Leads"
|
||||
class="oe_highlight"
|
||||
confirm="This will assign leads to all members. Do you want to proceed?"
|
||||
attrs="{'invisible': [('assignment_enabled', '=', False)]}"/>
|
||||
attrs="{'invisible': ['|', '&', ('use_leads', '=', False), ('use_opportunities', '=', False), ('assignment_enabled', '=', False)]}"/>
|
||||
</header>
|
||||
</xpath>
|
||||
<xpath expr="//div[@name='options_active']" position="inside">
|
||||
@@ -162,6 +162,7 @@
|
||||
<field name="lead_all_assigned_month_count" class="oe_inline"/> /
|
||||
<field name="assignment_max" class="oe_inline"/>
|
||||
</div>
|
||||
<field name="assignment_optout" attrs="{'invisible': [('assignment_auto_enabled', '=', False)]}"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='member_ids']" position="attributes">
|
||||
<attribute name="attrs">{'invisible': [('assignment_enabled', '=', True)]}</attribute>
|
||||
|
||||
Reference in New Issue
Block a user