From c7a03dcd65f3a27477c9c6332b95e2cb74818423 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Mon, 13 Feb 2023 13:45:46 +0000 Subject: [PATCH] [PERF] crm: fix performances of activity report RATIONALE Activity report is slow, as it makes a complex query inside mail.message table which is one of our biggest table with crm.lead table, also a big table. This activity report could be speeduped by looking only on activities, not including discussions messages. SOLUTION Rationale is that discussions can be about whatever (real discussion with customers but also internal discussion, notes, ...). What matter here is to report on activities like phonecalls, followup emails, meetings, ... to have a global view of sales people activity. SPECIFICATIONS Remove inclusion of discussion messages in the query. Keep only activities-based messages. Task-3129356 (Crm: Fix activity report performances) Part-of: odoo/odoo#112535 --- addons/crm/report/crm_activity_report.py | 5 ++--- addons/crm/security/ir.model.access.csv | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/crm/report/crm_activity_report.py b/addons/crm/report/crm_activity_report.py index 4588cbda8cb..990066b5643 100644 --- a/addons/crm/report/crm_activity_report.py +++ b/addons/crm/report/crm_activity_report.py @@ -70,11 +70,10 @@ class ActivityReport(models.Model): """ def _where(self): - disccusion_subtype = self.env.ref('mail.mt_comment') return """ WHERE - m.model = 'crm.lead' AND (m.mail_activity_type_id IS NOT NULL OR m.subtype_id = %s) - """ % (disccusion_subtype.id,) + m.model = 'crm.lead' AND (m.mail_activity_type_id IS NOT NULL) + """ def init(self): tools.drop_view_if_exists(self._cr, self._table) diff --git a/addons/crm/security/ir.model.access.csv b/addons/crm/security/ir.model.access.csv index c51c011e970..08bcd246358 100644 --- a/addons/crm/security/ir.model.access.csv +++ b/addons/crm/security/ir.model.access.csv @@ -10,7 +10,8 @@ access_res_partner_category,res.partner.category.crm.user,base.model_res_partner access_crm_lost_reason_manager,crm.lost.reason.manager,model_crm_lost_reason,sales_team.group_sale_manager,1,1,1,1 access_crm_lost_reason_salesman,crm.lost.reason.salesman,model_crm_lost_reason,sales_team.group_sale_salesman,1,0,0,0 access_crm_lost_reason_user,crm.lost.reason.user,model_crm_lost_reason,base.group_user,1,0,0,0 -access_crm_activity_report_user,crm.activity.report.user,model_crm_activity_report,base.group_user,1,0,0,0 +access_crm_activity_report_user,crm.activity.report.user,model_crm_activity_report,base.group_user,0,0,0,0 +access_crm_activity_report_salesman,crm.activity.report.salesman,model_crm_activity_report,sales_team.group_sale_salesman,1,0,0,0 access_calendar_event_manager,calendar.event.manager,calendar.model_calendar_event,sales_team.group_sale_manager,1,1,1,1 access_calendar_event,calendar.event,calendar.model_calendar_event,sales_team.group_sale_salesman,1,1,1,0 access_calendar_event_type_sale_manager,calendar.event.type.manager,calendar.model_calendar_event_type,sales_team.group_sale_manager,1,1,1,0