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

Module: Agreement - Project

Entity: agreement

Compute Method: _compute_task_count

View 18.0 View 19.0
Inputs Method Outputs
  • id
+ groups = self.env["project.task"]._read_group(
+             [("agreement_id", "in", self.ids)],
+             groupby=["agreement_id"],
+             aggregates=["__count"],
+         )
+ counts = {agreement.id: count for agreement, count in groups}
for ag in self:
-             count = self.env["project.task"].search_count(
-                 [("agreement_id", "=", ag.id)]
-             )
-             ag.task_count = count
+             ag.task_count = counts.get(ag.id, 0)
  • task_count

Back to entity