[IMP] crm: add monthly lead assignment count color
Draw attention to the monthly assigned lead count when it is exceeding the limit by changing the text color to orange. Task-3204763 Part-of: odoo/odoo#115326
This commit is contained in:
@@ -43,6 +43,9 @@ class Team(models.Model):
|
||||
lead_all_assigned_month_count = fields.Integer(
|
||||
string='# Leads/Opps assigned this month', compute='_compute_lead_all_assigned_month_count',
|
||||
help="Number of leads and opportunities assigned this last month.")
|
||||
lead_all_assigned_month_exceeded = fields.Boolean('Exceed monthly lead assignement', compute="_compute_lead_all_assigned_month_count",
|
||||
help="True if the monthly lead assignment count is greater than the maximum assignment limit, false otherwise."
|
||||
)
|
||||
opportunities_count = fields.Integer(
|
||||
string='# Opportunities', compute='_compute_opportunities_data')
|
||||
opportunities_amount = fields.Monetary(
|
||||
@@ -82,10 +85,11 @@ class Team(models.Model):
|
||||
for team in self:
|
||||
team.lead_unassigned_count = counts.get(team.id, 0)
|
||||
|
||||
@api.depends('crm_team_member_ids.lead_month_count')
|
||||
@api.depends('crm_team_member_ids.lead_month_count', 'assignment_max')
|
||||
def _compute_lead_all_assigned_month_count(self):
|
||||
for team in self:
|
||||
team.lead_all_assigned_month_count = sum(member.lead_month_count for member in team.crm_team_member_ids)
|
||||
team.lead_all_assigned_month_exceeded = team.lead_all_assigned_month_count > team.assignment_max
|
||||
|
||||
def _compute_opportunities_data(self):
|
||||
opportunity_data = self.env['crm.lead']._read_group([
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
.o_crm_team_form_view {
|
||||
/*
|
||||
* Used to conditionnaly add a css class on a record field.
|
||||
* Add text-warning on the element with class o_crm_lead_month_assignment
|
||||
* only if the element with o_crm_lead_all_assigned_month_exceeded is visible
|
||||
* in the template.
|
||||
*/
|
||||
div.o_crm_lead_all_assigned_month_exceeded + .o_crm_lead_month_assignment {
|
||||
@extend .text-warning;
|
||||
}
|
||||
}
|
||||
@@ -183,9 +183,14 @@
|
||||
<xpath expr="//group[@name='right']" position="inside">
|
||||
<field name="assignment_enabled" invisible="1"/>
|
||||
<field name="assignment_auto_enabled" invisible="1"/>
|
||||
<div class="text-muted" colspan="2" attrs="{'invisible': [('assignment_enabled', '=', False)]}">
|
||||
<field name="lead_all_assigned_month_count" class="oe_inline"/><span> leads assigned this month
|
||||
on a maximum of </span><field name="assignment_max" class="oe_inline"/>
|
||||
<field name="lead_all_assigned_month_exceeded" invisible="1"/>
|
||||
<div colspan="2">
|
||||
<div class="o_crm_lead_all_assigned_month_exceeded" attrs="{'invisible': [('lead_all_assigned_month_exceeded', '=', False)]}"/>
|
||||
<div class="o_crm_lead_month_assignment text-muted" attrs="{'invisible': [('assignment_enabled', '=', False)]}">
|
||||
<i class="fa fa-info-circle me-2" title="Assigned Lead Count"/>
|
||||
<field name="lead_all_assigned_month_count" class="oe_inline"/><span> leads assigned this month
|
||||
on a maximum of </span><field name="assignment_max" class="oe_inline"/>
|
||||
</div>
|
||||
</div>
|
||||
<field name="assignment_domain" widget="domain" string="Domain"
|
||||
options="{'model': 'crm.lead', 'in_dialog': True}"
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
<field name="name">crm.team.form</field>
|
||||
<field name="model">crm.team</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Sales Team">
|
||||
<form string="Sales Team" class="o_crm_team_form_view">
|
||||
<div class="alert alert-info text-center" role="alert"
|
||||
attrs="{'invisible': ['|', ('is_membership_multi', '=', True), ('member_warning', '=', False)]}">
|
||||
<field name="member_warning"/>
|
||||
|
||||
Reference in New Issue
Block a user