Skip to content

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

Open
mav-adhoc wants to merge 1 commit into
OCA:19.0from
adhoc-dev:19.0-fix-purchase_deposit-guard-multicurrency-mav
Open

[FIX] purchase_deposit: convert deposit amounts to the order currency#3142
mav-adhoc wants to merge 1 commit into
OCA:19.0from
adhoc-dev:19.0-fix-purchase_deposit-guard-multicurrency-mav

Conversation

@mav-adhoc

Copy link
Copy Markdown
Contributor

Forward port of #3141.

Problem

When a deposit bill is posted, AccountMove.action_post writes its price unit back to the deposit line of the purchase order:

line.purchase_line_id.price_unit = line.price_unit

The amount is copied verbatim. A purchase order line holds amounts in the order currency, but the bill may well be issued in a different one — the vendor billing in the company currency while the order is in a foreign one, for instance. In that case the order line ends up holding a figure expressed in the wrong currency, off by the exchange rate.

The divergence is silent here: deposit lines carry product_qty = 0, so the wrong figure never reaches the order total and nothing in the UI flags it. Unlike 18.0, this branch has no check summing the deposit lines against the order total, so nothing surfaces the corrupted amount later either — it just sits in the order line, and a database upgraded from an earlier version carries it along.

Fix

Convert the amount to the order currency at the bill date. Bills sharing the order currency are unaffected: the conversion rate is 1 and round=False leaves the amount untouched.

Test plan

test_deposit_billed_in_another_currency: an order in a currency worth 1000x the company one, with a 300 deposit whose bill is switched to the company currency and billed as 300000. The order line must still read 300 after posting. Fails without the fix with 300000.0 != 300.0.

Module suite green.

Note this prevents the divergence, it does not repair deposit lines already written with an unconverted amount.

@OCA-git-bot OCA-git-bot added series:19.0 mod:purchase_deposit Module purchase_deposit labels Aug 6, 2026
When a deposit bill is posted, its price unit is written back to the
deposit line of the purchase order. The amount was copied verbatim, so a
bill issued in a currency other than the order one left the order line
holding a figure expressed in the wrong currency, off by the exchange
rate.

Convert the amount to the order currency at the bill date. Bills sharing
the order currency are unaffected, the conversion rate is 1 and the
result is not rounded.
@mav-adhoc
mav-adhoc force-pushed the 19.0-fix-purchase_deposit-guard-multicurrency-mav branch from 7495c36 to 66afe92 Compare August 6, 2026 18:53
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