-
Notifications
You must be signed in to change notification settings - Fork 23.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FIX] purchase_stock: Bill currency different than PO #162827
[FIX] purchase_stock: Bill currency different than PO #162827
Conversation
5170c9f
to
517cba4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello,
Maybe I missed something but when I create a bill, it is in the currency of the PO (€10/unit). Then if I switch the currency to $, it simply changes the sign without doing any conversion ($10/unit)
Then if I receive the product and look at the valuation, it will be in the main currency ($) and properly converted ($15.29/unit)
This is different from the steps you explained, so is there still a need for this PR?
it shouldn't have been converted that's the point |
hi @Sehnde you can refer to the test to check the incorrect behaviour |
@HANNICHE-Walid ok I see what you mean. Would you please update your commit and PR message to explain that? This is not clear. Now for your fix, it will immediately create a layer at the bill value in the company currency. So for the following case:
the SVL will be at $10 instead of $15.29 in a single layer. Comparatively, if def _action_done(self, cancel_backorder=False):
res = super()._action_done(cancel_backorder=cancel_backorder)
if res.product_id.purchase_method == 'purchase' and res.purchase_line_id.invoice_lines:
amls = res.purchase_line_id.invoice_lines
svls = res.stock_valuation_layer_ids
correction_svl_vals, _dummy = res.purchase_line_id.invoice_lines._generate_price_difference_vals(res.stock_valuation_layer_ids)
return res This is a very rough draft that does not care for multiple invoice lines or layers, but it works as a proof of concept. This is just an idea, do you have an opinion @amoyaux ? |
Why would you need a correction layer? When you receive the product you take the bill value and that's all |
R+ ? |
I wanted to keep the same behavior as when receiving quantities then invoicing a different total price. Not a good idea evidently. @HANNICHE-Walid some remarks from me:
This line made me think that the valuation layer was in the PO currency (€) with the bill value (10) so I was expecting to see €10 in valuation instead of $15.29
|
Steps to reproduce: > The Company Currency is the Dollar > Create a product > Set FIFO and Manual valuation > Set BIlling policy as Ordered Quantities > Create Purchase order in Euro > Create Vendor bill in USD (10 $) > Now Receive the quantities > Check the valuation > Wrong value (15.92 $) the value should be 10$ (taken from the bill) Bug: In the case of BIlling policy on Ordered Quantities and PO in a foreign currency we assume the bill will be in same currency as the PO Fix: currently unit price is first computed in PO currency and then converted in the end to company currency added conversion from bill to PO opw-3805454 also fixed a rounding issue opw-3773413 alternative fix: compute everything in company currency (odoo#155937)
517cba4
to
26db1c6
Compare
this was also done to account for the case of the bill being in another different currency aswell (although an unlikely scenario) |
hi @Sehnde I have updated the PR |
@amoyaux R+ please |
robodoo delegate+ |
@robodoo r+ |
Steps to reproduce: > The Company Currency is the Dollar > Create a product > Set FIFO and Manual valuation > Set BIlling policy as Ordered Quantities > Create Purchase order in Euro > Create Vendor bill in USD (10 $) > Now Receive the quantities > Check the valuation > Wrong value (15.92 $) the value should be 10$ (taken from the bill) Bug: In the case of BIlling policy on Ordered Quantities and PO in a foreign currency we assume the bill will be in same currency as the PO Fix: currently unit price is first computed in PO currency and then converted in the end to company currency added conversion from bill to PO opw-3805454 also fixed a rounding issue opw-3773413 alternative fix: compute everything in company currency (#155937) closes #162827 Signed-off-by: Walid Hanniche (waha) <waha@odoo.com>
@HANNICHE-Walid this pull request has forward-port PRs awaiting action (not merged or closed): |
1 similar comment
@HANNICHE-Walid this pull request has forward-port PRs awaiting action (not merged or closed): |
Steps to reproduce:
Bug:
In the case of BIlling policy on Ordered Quantities and PO in a foreign
currency we assume the bill will be in same currency as the PO
Fix:
currently unit price is first computed in PO currency and then converted
in the end to company currency added conversion from bill to PO
opw-3805454
also fixed a rounding issue opw-3773413
alternative fix:
compute everything in company currency (#155937)