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

Module: Field Service Recurring Work Orders

Entity: fsm.recurring

Compute Method: _compute_order_count

Inputs Method Outputs
data = self.env["fsm.order"]._read_group(
            domain=Domain.AND(
                [
                    Domain("fsm_recurring_id", "in", self.ids),
                    Domain(
                        "stage_id",
                        "!=",
                        self.env.ref("fieldservice.fsm_stage_cancelled").id,
                    ),
                ]
            ),
            groupby=["fsm_recurring_id"],
            aggregates=["__count"],
        )
for recurring in self:
            count_data = next(filter(lambda r: r[0] == recurring, data), None)
            recurring.fsm_order_count = count_data[1] if count_data else 0

Back to entity