[IMP] resource: Index calendar/resources on calendar leaves

Improves performances, notably on the method  https://github.com/odoo/odoo/blame/14.0/addons/resource/models/resource.py#L487

closes odoo/odoo#62821

X-original-commit: fc962de2b60adaa1ffa3bf70bfadc5c3d17867b3
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
This commit is contained in:
Yannick Tivisse
2020-12-03 13:00:41 +00:00
parent 584bcb9025
commit 0b07defece
+2 -2
View File
@@ -1005,11 +1005,11 @@ class ResourceCalendarLeaves(models.Model):
company_id = fields.Many2one(
'res.company', related='calendar_id.company_id', string="Company",
readonly=True, store=True)
calendar_id = fields.Many2one('resource.calendar', 'Working Hours')
calendar_id = fields.Many2one('resource.calendar', 'Working Hours', index=True)
date_from = fields.Datetime('Start Date', required=True)
date_to = fields.Datetime('End Date', required=True)
resource_id = fields.Many2one(
"resource.resource", 'Resource',
"resource.resource", 'Resource', index=True,
help="If empty, this is a generic time off for the company. If a resource is set, the time off is only for this resource")
time_type = fields.Selection([('leave', 'Time Off'), ('other', 'Other')], default='leave',
help="Whether this should be computed as a time off or as work time (eg: formation)")