[16.0][FIX] pms: realign payment journal items partner on reconcile - #449
Open
DarioLodeiros wants to merge 1 commit into
Open
DarioLodeiros wants to merge 1 commit into
DarioLodeiros wants to merge 1 commit into
Conversation
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
force-pushed
the
16.0-fix-payment-partner-move-lines
branch
from
September 14, 2026 09:03
8d7636c to
fab716c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The journal items of an
account.paymentkeep 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, andaccount.move.line.partner_idis deliberately not recomputed from its move (see the# Do not depend on 'move_id.partner_id'comment inaccount/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 byold_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, andreconcile()now calls it for every payment involved, whether or not the partner had to be copied from an invoice._seek_for_lines()). Write-off lines may legitimately carry a different partner, and core preserves them as well.partner_idis protected by the fiscal lock date, and raising there would break the reconciliation for users without accounting adviser rights.self.payment_idinstead ofself, so a payment is not processed once per journal item.Tests
Two tests in
TestPmsPayment:16.0without this commit, withAssertionError: 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.