Skip to content

[16.0][FIX] pms: realign payment journal items partner on reconcile - #449

Open
DarioLodeiros wants to merge 1 commit into
OCA:16.0from
commitsun:16.0-fix-payment-partner-move-lines
Open

DarioLodeiros wants to merge 1 commit into
OCA:16.0from
commitsun:16.0-fix-payment-partner-move-lines

Conversation

@DarioLodeiros

@DarioLodeiros DarioLodeiros commented Sep 14, 2026

Copy link
Copy Markdown
Member

Problem

The journal items of an account.payment keep a stale partner when the partner of the payment is corrected without the payment record itself being rewritten.

Odoo regenerates the journal items of a payment only from _synchronize_to_moves, i.e. when the payment is written, and account.move.line.partner_id is deliberately not recomputed from its move (see the # Do not depend on 'move_id.partner_id' comment in account/models/account_move_line.py).

AccountMoveLine.reconcile() already copies the partner of the reconciled invoice onto the payment, and the journal items were repaired as a side effect of that write. But the copy is guarded by old_partner != new_partner: if the partner of the payment has already been corrected by hand before reconciling, nothing is written, the journal items are never rewritten, and the payment stays under the wrong partner in the partner ledger forever.

Fix

account.payment._realign_move_lines_partner() writes the partner of the payment on its journal items whenever they diverge, and reconcile() now calls it for every payment involved, whether or not the partner had to be copied from an invoice.

  • Only the liquidity and counterpart lines are touched (_seek_for_lines()). Write-off lines may legitimately carry a different partner, and core preserves them as well.
  • Entries inside a locked period are skipped: partner_id is protected by the fiscal lock date, and raising there would break the reconciliation for users without accounting adviser rights.
  • The payment loop now iterates self.payment_id instead of self, so a payment is not processed once per journal item.

Tests

Two tests in TestPmsPayment:

  • the partner of the invoice is propagated to the journal items (existing behaviour),
  • the journal items are realigned even when the partner of the payment is already the right one. This one fails on 16.0 without this commit, with AssertionError: res.partner(x,) != res.partner(y,).

The test helper loads a chart of accounts on the PMS test company, which is created from scratch and cannot register payments or invoice folios otherwise.

Odoo only rewrites the journal items of a payment when the payment itself is
written (_synchronize_to_moves), and the partner of a journal item is never
recomputed from its move. So the partner of a payment can be corrected while
its journal items keep the original one.

Until now those journal items were only repaired as a side effect of copying
the partner of the reconciled invoice onto the payment. When the partner of
the payment had already been corrected by hand there was nothing left to
propagate, the journal items were never rewritten, and the partner ledger
kept reporting the payment under the wrong partner.

Realign them explicitly after reconciling. Entries inside a locked period are
skipped, because partner_id is protected by the fiscal lock date and raising
there would break the reconciliation for the user.
@DarioLodeiros
DarioLodeiros force-pushed the 16.0-fix-payment-partner-move-lines branch from 8d7636c to fab716c Compare September 14, 2026 09:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants