[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
This commit is contained in:
Thibault Delavallée
2023-03-09 10:51:37 +01:00
parent 9bb1d37924
commit c7a03dcd65
2 changed files with 4 additions and 4 deletions
+2 -3
View File
@@ -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)
+2 -1
View File
@@ -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
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
10 access_crm_lost_reason_manager crm.lost.reason.manager model_crm_lost_reason sales_team.group_sale_manager 1 1 1 1
11 access_crm_lost_reason_salesman crm.lost.reason.salesman model_crm_lost_reason sales_team.group_sale_salesman 1 0 0 0
12 access_crm_lost_reason_user crm.lost.reason.user model_crm_lost_reason base.group_user 1 0 0 0
13 access_crm_activity_report_user crm.activity.report.user model_crm_activity_report base.group_user 1 0 0 0 0
14 access_crm_activity_report_salesman crm.activity.report.salesman model_crm_activity_report sales_team.group_sale_salesman 1 0 0 0
15 access_calendar_event_manager calendar.event.manager calendar.model_calendar_event sales_team.group_sale_manager 1 1 1 1
16 access_calendar_event calendar.event calendar.model_calendar_event sales_team.group_sale_salesman 1 1 1 0
17 access_calendar_event_type_sale_manager calendar.event.type.manager calendar.model_calendar_event_type sales_team.group_sale_manager 1 1 1 0