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

Module: Payment - Account

Entity: account.payment

Compute Method: _compute_refunds_count

Inputs Method Outputs
  • id
rg_data = self.env['account.payment']._read_group(
            domain=[
                ('source_payment_id', 'in', self.ids),
                ('payment_transaction_id.operation', '=', 'refund')
            ],
            groupby=['source_payment_id'],
            aggregates=['__count']
        )
data = {source_payment.id: count for source_payment, count in rg_data}
for payment in self:
            payment.refunds_count = data.get(payment.id, 0)

Back to entity