From a8e9b257610ecb60ed827b42f7657f9401cc3569 Mon Sep 17 00:00:00 2001 From: amdi-odoo Date: Thu, 4 May 2023 12:35:57 +0000 Subject: [PATCH] [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 --- addons/crm/models/crm_team.py | 6 +++++- addons/crm/static/src/scss/crm_team.scss | 11 +++++++++++ addons/crm/views/crm_team_views.xml | 11 ++++++++--- addons/sales_team/views/crm_team_views.xml | 2 +- 4 files changed, 25 insertions(+), 5 deletions(-) create mode 100644 addons/crm/static/src/scss/crm_team.scss diff --git a/addons/crm/models/crm_team.py b/addons/crm/models/crm_team.py index 575fe878102..4ada6a3b3b2 100644 --- a/addons/crm/models/crm_team.py +++ b/addons/crm/models/crm_team.py @@ -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([ diff --git a/addons/crm/static/src/scss/crm_team.scss b/addons/crm/static/src/scss/crm_team.scss new file mode 100644 index 00000000000..df67dc03dfa --- /dev/null +++ b/addons/crm/static/src/scss/crm_team.scss @@ -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; + } +} diff --git a/addons/crm/views/crm_team_views.xml b/addons/crm/views/crm_team_views.xml index 769c3c42ca7..15f459bb46c 100644 --- a/addons/crm/views/crm_team_views.xml +++ b/addons/crm/views/crm_team_views.xml @@ -183,9 +183,14 @@ -
- leads assigned this month - on a maximum of + +
+
+
+ + leads assigned this month + on a maximum of +
crm.team.form crm.team -
+