[IMP] purchase_deposit: make the deposit over total check optional - #3182
Merged
OCA-git-bot merged 1 commit intoSep 25, 2026
Conversation
Forward port of OCA#3172. The check added in OCA#2788 never reached this branch, so it arrives here already behind the company setting "Limit Deposits to Order Total", disabled by default: the module keeps the behaviour it has today, and a deployment that wants the ceiling enables it in Purchase > Configuration > Settings. It is not enforced by default because: - it compares the deposit lines' price_unit (tax excluded) against order.amount_total (tax included), so the effective ceiling depends on whether the order has taxes. Deposit lines also carry product_qty = 0 and never contribute to amount_total. - when the order is in a foreign currency and the vendor invoices the deposits in the company currency, each deposit line holds an amount converted at the rate of its own bill date, so the sum it adds up has no single right value to compare against. The error message states the amounts and the currency, so that a refusal can be read without opening the order. The configuration fragment is renamed to CONFIGURE.md, the name the readme generator looks for, so that it reaches README.rst at last.
Contributor
Author
|
@HviorForgeFlow Can you review it please? Thanks! |
UsmanGhias
reviewed
Sep 25, 2026
UsmanGhias
left a comment
There was a problem hiding this comment.
Clean patch for OCA/purchase-workflow.
Observations:
- Code structure follows standard OCA guidelines and cleanly isolates the extension logic.
Ready for testing on standard environments.
Best,
Usman
HviorForgeFlow
approved these changes
Sep 25, 2026
Member
|
/ocabot merge minor |
Contributor
|
Hey, thanks for contributing! Proceeding to merge this for you. |
Contributor
|
Congratulations, your PR was merged at c3edd5c. Thanks a lot for contributing to OCA. ❤️ |
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.
What
Forward port of #3172, as asked for there.
The "deposit can't be greater than the PO total" check added in #2788 never
reached this branch, so it arrives here already behind the company setting
Limit Deposits to Order Total, disabled by default. Nothing changes for an
existing deployment: a deposit over the order total is still accepted, and the
ceiling is opt-in from Purchase > Configuration > Settings.
Why it is disabled by default
1. The two sides of the comparison are not the same base. It sums the deposit
lines'
price_unit, which is tax excluded, and compares it againstorder.amount_total, which is tax included. The effective ceiling therefore depends onwhether the order carries taxes: the untaxed total on a tax exempt order, the tax
included total on a taxed one. Deposit lines also carry
product_qty = 0, so they nevercontribute to
amount_totalthemselves.2. On a multi-currency order the sum it compares has no single right value. When the
order is in a foreign currency and the vendor bills the deposits in the company
currency, each deposit line holds an amount converted from the bill. Whichever rate that
conversion uses, the sum cannot serve as a hard limit:
the order floats with the exchange rate. An order advanced in fixed instalments of the
company currency stops adding up, and the last instalment is refused even though every
single amount is right.
purchase.order.currency_rate) a fully advanced order doesadd up — but only while that rate is still meaningful. On an order paid over a year or
more in a high-inflation company currency, the order rate is stale and it inflates
every later deposit instead.
That is not a bug in either conversion — an exchange difference on a prepayment is real
and has to be recognised somewhere. But it has to be recognised in the accounting of the
bills, not charged against a commercial control that then refuses the operation. For
reference, core
salehandles the same situation with a non-blocking warning in thewizard (
display_invoice_amount_warning) rather than an error.There is no migration script: the setting starts disabled everywhere.
The error message states the deposit total, the order total and the currency, so a
refusal can be read without opening the order.
The readme fragment is renamed
CONFIGURATION.rst→CONFIGURE.md, the name the readmegenerator looks for; the old one never reached
README.rst.README.rstitself is leftto the bot, as the CI expects for PRs that touch readme fragments.
Test plan
test_not_allow_deposit_greater_than_po_totalandtest_not_allow_deposit_over_total_with_deposit_already_invoicedcover the check withthe setting enabled. Both fail if the guarded block is removed.
test_allow_deposit_greater_than_po_total_by_defaultcovers the default: the samedeposit that the check refuses is created.
0 failed, 0 error(s) of 9 tests.