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.payment
Compute Method: _compute_state
| Inputs | Method | Outputs |
|---|---|---|
|
+ payments_is_matched_to_recompute = self.env['account.payment'] + for payment in self: + if not payment.state: + payment.state = 'draft' + # in_process --> paid + if (move := payment.move_id) and payment.state in ('paid', 'in_process'): + liquidity, _counterpart, _writeoff = payment._seek_for_lines() + payment.state = ( + 'paid' + if move.company_currency_id.is_zero(sum(liquidity.mapped('amount_residual'))) or not any(liquidity.account_id.mapped('reconcile')) else + 'in_process' + ) + if ( + payment.state == 'in_process' and ( + payment.reconciled_invoice_ids and all(invoice.payment_state == 'paid' for invoice in payment.reconciled_invoice_ids) + or payment.reconciled_bill_ids and all(bill.payment_state == 'paid' for bill in payment.reconciled_bill_ids) + ) + ): + # The access to invoice.payment_state will trigger a flush_model on account_payment.is_matched in its compute. + # This flush will then trigger _compute_reconciliation_status. However, the payment.state will then be changed by this next line of code. + # As the _compute_reconciliation_status was already tiggered once, we have to force the recompute after the payment state has been updated, + # since the values computed by that method depends on it. + payment.state = 'paid' + payments_is_matched_to_recompute |= payment + self.env.add_to_compute(self._fields['is_matched'], payments_is_matched_to_recompute) |
|
