[18.0][IMP] account_payment_line: restrict counterpart lines to payment partner - #962
Open
rjaraspearhead wants to merge 1 commit into
Conversation
Contributor
|
Hi @ChrisOForgeFlow, |
Author
|
Hi @celm1990, @ChrisOForgeFlow, @xaviedoanhduy, @AlexPForgeFlow — could you review this |
…tner By default the counterpart lines of a payment accept any partner, which allows applying invoices of a partner different from the one registered in the payment header. Add an optional company setting, disabled by default
rjaraspearhead
force-pushed
the
18.0-add-account_payment_line-restrict-counterpart-partner
branch
from
July 27, 2026 14:14
ad49258 to
2b45e7c
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.
Context
The counterpart lines of a payment currently accept any partner. This makes it
possible to register a payment for one partner and then apply, in its
counterpart lines, invoices belonging to a completely different partner. Some
companies rely on that to move balances between partners, but for others it is
a source of reconciliation errors that are hard to spot afterwards.
What this PR does
Adds an optional company setting to forbid it, disabled by default, so the
current behaviour is unchanged for everybody who does not opt in:
res.company.payment_line_restrict_counterpart_partner, exposed inInvoicing / Settings through
res.config.settings.the commercial entity of the payment partner. When the payment has no partner
yet, the selection is blocked rather than falling back to every partner.
@api.constrainson the counterpart line rejects lines whose partner,move or journal item belongs to a different commercial entity, so the
restriction is enforced on save and not only in the UI.
Using the commercial entity means invoices of child contacts of the payment
partner are still accepted, which is the usual expectation.
How to test
another partner (existing behaviour).
Settings.
A or one of its contacts, and saving a line for partner B raises a
ValidationError.Covered by
test_12_restrict_counterpart_partner.