From ed484ba8bcdf4db8a495f78c31f0bdb2fe10d55b Mon Sep 17 00:00:00 2001 From: "Xavier BOL (xbo)" Date: Thu, 24 Feb 2022 13:26:42 +0000 Subject: [PATCH] [IMP] hr_timesheet: add index in project_id on timesheets model Before this commit, a search to find the timesheets is slow because the model containing the timesheets contained also the basic AAL and so many records could be stored into that model. This commit adds an index on project_id field in that model to search quicker than before the timesheets since a AAL is a timesheet when the `project_id` field is set. Closes #85513 X-original-commit: 8cc4006 Part-of: odoo/odoo#85968 Co-authored-by: Yannick Tivisse Co-authored-by: Laurent Stukkens (LTU) --- addons/hr_timesheet/models/hr_timesheet.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/hr_timesheet/models/hr_timesheet.py b/addons/hr_timesheet/models/hr_timesheet.py index a639ec2a3f2..85d5973f751 100644 --- a/addons/hr_timesheet/models/hr_timesheet.py +++ b/addons/hr_timesheet/models/hr_timesheet.py @@ -44,7 +44,7 @@ class AccountAnalyticLine(models.Model): compute='_compute_task_id', store=True, readonly=False, domain="[('company_id', '=', company_id), ('project_id.allow_timesheets', '=', True), ('project_id', '=?', project_id)]") project_id = fields.Many2one( - 'project.project', 'Project', domain=_domain_project_id, + 'project.project', 'Project', domain=_domain_project_id, index=True, compute='_compute_project_id', store=True, readonly=False) user_id = fields.Many2one(compute='_compute_user_id', store=True, readonly=False) employee_id = fields.Many2one('hr.employee', "Employee", domain=_domain_employee_id, context={'active_test': False})