Odoo Mindscape. Understand Odoo faster. Explore modules, fields, dependencies and version differences in one place instead of digging through the source code.

Module: Time Off

Entity: hr.leave

Compute Method: _compute_leaves

View 19.0
Inputs Method Outputs
  • employee_id
  • holiday_status_id
  • date_to
+ date_from = fields.Date.from_string(self.env.context['default_request_date_from']) if 'default_request_date_from' in self.env.context else fields.Date.today()
+ employee_days_per_allocation = self.employee_id._get_consumed_leaves(self.holiday_status_id, date_from)[0]
+ for leave in self:
+             virtual_remaining_leaves = 0
+             max_leaves = 0
+             for allocation, allocation_dict in employee_days_per_allocation[leave.employee_id][leave.holiday_status_id].items():
+                 if allocation and (not allocation.date_to or allocation.date_to >= date_from):
+                     max_leaves += allocation_dict['max_leaves']
+                     virtual_remaining_leaves += allocation_dict['virtual_remaining_leaves']
+             leave.virtual_remaining_leaves = virtual_remaining_leaves
+             leave.max_leaves = max_leaves
  • virtual_remaining_leaves
  • max_leaves

Back to entity