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

Module: Sales - Project

Entity: project.project

Compute Method: _compute_invoice_count

Inputs Method Outputs
  • account_id
  • account_id.ids
  • account_id.id
data = self.env['account.move.line']._read_group(
            [('move_id.move_type', 'in', ['out_invoice', 'out_refund']), ('analytic_distribution', 'in', self.account_id.ids)],
            groupby=['analytic_distribution'],
            aggregates=['__count'],
        )
data = {int(account_id): move_count for account_id, move_count in data}
for project in self:
            project.invoice_count = data.get(project.account_id.id, 0)

Back to entity