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

Module: Employees

Entity: hr.employee

Compute Method: _compute_current_version_id

View 20.0
Inputs Method Outputs
  • version_ids
  • current_version_id
+ today = fields.Date.context_today(self)
+ for employee in self:
+             version = self.env['hr.version'].search(
+                 [
+                     ('employee_id', 'in', employee.ids),
+                     ('date_version', '<=', today),
+                     ('active', '=', True),
+                 ],
+                 order='date_version desc',
+                 limit=1,
+             )
+             new_current_version = False
+             if version:
+                 new_current_version = version
+             elif employee.version_ids:
+                 new_current_version = employee.version_ids[0]
+             # To not trigger computed properties if still the same version
+             if employee.current_version_id != new_current_version:
+                 employee.current_version_id = new_current_version
  • current_version_id

Back to entity