[16.0] [FIX] sale_order_invoice_amount: invoiced_amount value when SO and invoices share a foreign currency#4382
Open
Tisho99 wants to merge 2 commits into
Open
Conversation
…voices share a foreign currency
4dc68fa to
b288ccf
Compare
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.
Fixes the use case explained in #4337
Unit tests have been improved in a separate commit. The hardcoded invoiced amounts used in the asserts contained very specific decimal overflow errors that are only present in this version (see version 18.0), and causes the tests be less robust.
Regarding the FIX:
The
rec.invoiced_amount += invoice.amount_total_signedline only works correcly if both monetary fields have the same currency. rec.currency_id for rec.invoiced_amount, and invoice.company_currency_id for invoice.amount_total_signed. A condition to verify that has been added.The
rec.invoiced_amount += invoice.currency_id._convert( invoice.amount_total_in_currency_signed, rec.currency_id, invoice.company_id, invoice.invoice_date or fields.Date.today() )operation correctly converts all currencies to the sale currency, as the amount_total_in_currency_signed already has the total amount of the invoice converted to the currency of the invoice (In case the currency of the invoice and the company currency are different). Taking this into account, that operation has been moved to the else directive, applying it in the rest of the casesA unit test of this use case has been added. This tests fails without this FIX