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

Module: Invoicing

Entity: account.analytic.account

Compute Method: _compute_invoice_count

Inputs Method Outputs
  • id
sale_types = self.env['account.move'].get_sale_types(include_receipts=True)
data = self.env['account.move.line']._read_group(
            [
                ('parent_state', '=', 'posted'),
                ('move_id.move_type', 'in', sale_types),
                ('analytic_distribution', 'in', self.ids),
            ],
            ['analytic_distribution'],
            ['__count'],
        )
data = {int(account_id): move_count for account_id, move_count in data}
for account in self:
            account.invoice_count = data.get(account.id, 0)

Back to entity