Skip to content

[FIX] purchase_deposit: convert deposit amounts to the order currency - #3141

Merged
OCA-git-bot merged 1 commit into
OCA:18.0from
adhoc-dev:18.0-fix-purchase_deposit-guard-multicurrency-mav
Sep 10, 2026
Merged

OCA-git-bot merged 1 commit into
OCA:18.0from
adhoc-dev:18.0-fix-purchase_deposit-guard-multicurrency-mav

Conversation

@mav-adhoc

@mav-adhoc mav-adhoc commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

What

action_post copies the deposit amount from the vendor bill back into the purchase
order line. When the bill is issued in a currency other than the order one the figure
was copied verbatim, so an order in a strong currency ended up with a deposit line
holding the nominal of a weak one — three orders of magnitude off, in the case that
brought us here.

This converts it to the order currency, at the bill date.

Why it matters beyond the wrong figure

The deposit line's price_unit is not only informative: it is the amount deducted from
the final bill (_prepare_account_move_line puts the deposit line in with
quantity = -qty_invoiced), and on 18.0 it is also what the wizard compares against the
order total. So a bill figure landing there unconverted both corrupts the deduction and,
on 18.0, makes any further deposit on that order impossible.

Deposits billed in the order currency are unaffected: the conversion rate is exactly 1.

Test plan

test_deposit_billed_in_another_currency: an order in a currency worth 1000x the
company one, a deposit of 300, and a bill edited to the company currency for 300,000.
Without the fix the order line ends up at 300000.0; with it, at 300.0.

Full suite green (7 tests on 18.0, 6 on 19.0).

@OCA-git-bot OCA-git-bot added series:18.0 mod:purchase_deposit Module purchase_deposit labels Aug 5, 2026
@mav-adhoc
mav-adhoc force-pushed the 18.0-fix-purchase_deposit-guard-multicurrency-mav branch from 9e871e3 to b498a11 Compare August 5, 2026 19:30
@mav-adhoc
mav-adhoc force-pushed the 18.0-fix-purchase_deposit-guard-multicurrency-mav branch from b498a11 to 884686c Compare August 6, 2026 18:52
@mav-adhoc

Copy link
Copy Markdown
Contributor Author

Hi @HviorForgeFlow! Can you review the fix please? Thanks

@les-adhoc les-adhoc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mav-adhoc
mav-adhoc force-pushed the 18.0-fix-purchase_deposit-guard-multicurrency-mav branch from 884686c to ebe6fbb Compare September 8, 2026 18:25
@mav-adhoc mav-adhoc changed the title [FIX] purchase_deposit: convert deposit amounts to the order currency [FIX] purchase_deposit: measure the deposit at the order rate Sep 8, 2026
@mav-adhoc

Copy link
Copy Markdown
Contributor Author

Applied the review suggestions in both branches: the test case now inherits from BaseCommon and builds its data with Command.create. Thanks @BhaveshHeliconia.

Heads-up, since this was already approved: the fix itself changed. It used to convert the deposit at the bill date, it now converts at the order rate (purchase.order.currency_rate), which is the basis the order total already uses. The reasoning is in the updated description — converting at the bill date makes the amount left to bill on an order float with the exchange rate, and a fully advanced order stops adding up. The test was extended so it discriminates between the two. Worth a fresh look rather than carrying the previous approval over.

@mav-adhoc
mav-adhoc force-pushed the 18.0-fix-purchase_deposit-guard-multicurrency-mav branch from ebe6fbb to 639583b Compare September 8, 2026 18:33
@mav-adhoc mav-adhoc changed the title [FIX] purchase_deposit: measure the deposit at the order rate [FIX] purchase_deposit: convert deposit amounts to the order currency Sep 8, 2026
@mav-adhoc

Copy link
Copy Markdown
Contributor Author

Sorry for the churn: I briefly pushed a version that converted the deposit at the order rate instead of the bill date, and I have reverted it. It looked like the better basis — it is the one purchase.order.currency_rate/amount_total_cc use, and it makes an order advanced in fixed instalments of the company currency add up exactly. But measuring an old order at its own rate is only right while that rate is still meaningful: on a long-lived order in a foreign currency, paid over a year or more in a high-inflation company currency, the order rate is stale and it inflates every later deposit. I checked it against real orders and it would have newly blocked several of them, some by a wide margin. There is no single conversion basis that is right for every order, so this PR stays on the bill date and the deposit stays worth what was actually paid.

The only difference from the version you approved is your two test suggestions, now applied in both branches. Thanks again @BhaveshHeliconia.

@BhaveshHeliconia BhaveshHeliconia left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

When the vendor bills a deposit in a currency other than the order one,
action_post copied the bill figure into the order line verbatim, so an
order in a strong currency ended up holding the nominal of a weak one.
Convert it at the bill date instead.

Deposits billed in the order currency are unaffected: the conversion
rate is exactly 1.
@mav-adhoc
mav-adhoc force-pushed the 18.0-fix-purchase_deposit-guard-multicurrency-mav branch from 639583b to d09be0d Compare September 9, 2026 15:13
@mav-adhoc

Copy link
Copy Markdown
Contributor Author

Dropped the manifest version bump here too, per @HviorForgeFlow's review on #3142 — ocabot does it on merge, so no nobump needed on any of the three.

@mav-adhoc

Copy link
Copy Markdown
Contributor Author

For whoever merges: the red runboat/build here is not this PR. Every build of the 18.0 branch is failing at init, including the branch build itself (11184a7d7), while 19.0 deploys fine; the failures cluster on the heaviest branches across OCA repos and the platform reports its deployment cap reached. Reported upstream in sbidoul/runboat#158 with the details. Everything else — pre-commit, test with Odoo, test with OCB, codecov — is green.

@HviorForgeFlow

Copy link
Copy Markdown
Member

/ocabot merge patch

@OCA-git-bot

Copy link
Copy Markdown
Contributor

Hey, thanks for contributing! Proceeding to merge this for you.
Prepared branch 18.0-ocabot-merge-pr-3141-by-HviorForgeFlow-bump-patch, awaiting test results.

@OCA-git-bot
OCA-git-bot merged commit 0b28726 into OCA:18.0 Sep 10, 2026
8 of 9 checks passed
@OCA-git-bot

Copy link
Copy Markdown
Contributor

Congratulations, your PR was merged at 0d84290. Thanks a lot for contributing to OCA. ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants