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

Module: Project timesheet time control

Entity: hr.timesheet.time_control.mixin

Compute Method: _compute_show_time_control

Inputs Method Outputs
  • id
"""Decide which time control button to show, if any."""
related_field = self._relation_with_timesheet_line()
grouped = self.env["account.analytic.line"].read_group(
            domain=self._timesheet_running_domain(),
            fields=["id"],
            groupby=[related_field],
        )
lines_per_record = {
            group[related_field][0]: group[f"{related_field}_count"]
            for group in grouped
        }
button_per_lines = {0: "start", 1: "stop"}
for record in self:
            record.show_time_control = button_per_lines.get(
                lines_per_record.get(record.id, 0),
                False,
            )

Back to entity