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

Module: Task Logs

Entity: hr.employee

Compute Method: _compute_has_timesheet

View 18.0 View 19.0
Inputs Method Outputs
  • id
- self.env.cr.execute("""
-         SELECT id, EXISTS(SELECT 1 FROM account_analytic_line WHERE project_id IS NOT NULL AND employee_id = e.id limit 1)
-           FROM hr_employee e
-          WHERE id in %s
-         """, (tuple(self.ids), ))
- result = {eid[0]: eid[1] for eid in self.env.cr.fetchall()}
+ if self.ids:
+             result = dict(self.env.execute_query(SQL(
+                 """ SELECT id, EXISTS(
+                             SELECT 1 FROM account_analytic_line
+                              WHERE project_id IS NOT NULL AND employee_id = e.id
+                              LIMIT 1)
+                       FROM hr_employee e
+                      WHERE id in %s """,
+                 tuple(self.ids),
+             )))
+         else:
+             result = {}
for employee in self:
-             employee.has_timesheet = result.get(employee.id, False)
+             employee.has_timesheet = result.get(employee._origin.id, False)
  • has_timesheet

Back to entity