[FIX] purchase_deposit: convert deposit amounts to the order currency - #3142
OCA-git-bot merged 1 commit into
Conversation
7495c36 to
66afe92
Compare
BhaveshHeliconia
left a comment
There was a problem hiding this comment.
LGTM!
Just minor comments
| from odoo.tests import TransactionCase | ||
|
|
||
|
|
||
| class TestPurchaseDepositMultiCurrency(TransactionCase): |
There was a problem hiding this comment.
| class TestPurchaseDepositMultiCurrency(TransactionCase): | |
| class TestPurchaseDepositMultiCurrency(Basecommon): |
| ( | ||
| 0, | ||
| 0, |
There was a problem hiding this comment.
| ( | |
| 0, | |
| 0, | |
| Command.create( |
| ( | ||
| 0, | ||
| 0, |
There was a problem hiding this comment.
| ( | |
| 0, | |
| 0, | |
| Command.create( |
|
Hi @HviorForgeFlow! Can you review the fix please? Thanks |
66afe92 to
a68b654
Compare
|
Applied the review suggestions in both branches: the test case now inherits from 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 ( |
a68b654 to
e4bedf7
Compare
|
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 The only difference from the version you approved is your two test suggestions, now applied in both branches. Thanks again @BhaveshHeliconia. |
HviorForgeFlow
left a comment
There was a problem hiding this comment.
Code looks good, thanks for the contribution.
Just a minor alignment
| { | ||
| "name": "Purchase Deposit", | ||
| "version": "19.0.1.0.0", | ||
| "version": "19.0.1.0.1", |
There was a problem hiding this comment.
don't change version, ocabot will do
4b274ff to
03be572
Compare
|
Thanks @HviorForgeFlow. Version bump dropped, the manifest is untouched now — same in the 18.0 counterpart (#3141) and in #3172, so all three can be merged with the plain About the red I tracked it down and it is a core change: since odoo/odoo#285946 the read-only label of |
|
Sorry @mav-adhoc you are not allowed to merge. To do so you must either have push permissions on the repository, or be a declared maintainer of all modified addons. If you wish to adopt an addon and become it's maintainer, open a pull request to add your GitHub login to the |
| } | ||
| ) | ||
|
|
||
| def test_deposit_billed_in_another_currency(self): |
There was a problem hiding this comment.
Could you add this test case to test_purchase_deposit.py instead of creating a separate test file?
Also, if AI was used for this contribution, please add the Assisted-by: trailer according to the OCA AI policy.
There was a problem hiding this comment.
Attend comments @mav-adhoc, moving test is enough for now
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. Assisted-by: Claude Opus 5
03be572 to
1937d19
Compare
|
@Saran440 @HviorForgeFlow Done! Thnaks to both of you! |
|
/ocabot merge patch |
|
On my way to merge this fine PR! |
|
This PR has the |
|
Congratulations, your PR was merged at e19c41a. Thanks a lot for contributing to OCA. ❤️ |
What
action_postcopies the deposit amount from the vendor bill back into the purchaseorder 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_unitis not only informative: it is the amount deducted fromthe final bill (
_prepare_account_move_lineputs the deposit line in withquantity = -qty_invoiced), and on 18.0 it is also what the wizard compares against theorder 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 thecompany 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, at300.0.Full suite green (7 tests on 18.0, 6 on 19.0).