Skip to content

[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
OCA:16.0from
sygel-technology:16.0-fix-sale_order_invoice_amount
Open

[16.0] [FIX] sale_order_invoice_amount: invoiced_amount value when SO and invoices share a foreign currency#4382
Tisho99 wants to merge 2 commits into
OCA:16.0from
sygel-technology:16.0-fix-sale_order_invoice_amount

Conversation

@Tisho99
Copy link
Copy Markdown
Contributor

@Tisho99 Tisho99 commented Jun 2, 2026

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_signed line 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 cases

A unit test of this use case has been added. This tests fails without this FIX

@OCA-git-bot OCA-git-bot added series:16.0 mod:sale_order_invoice_amount Module sale_order_invoice_amount labels Jun 2, 2026
@Tisho99 Tisho99 force-pushed the 16.0-fix-sale_order_invoice_amount branch from 4dc68fa to b288ccf Compare June 2, 2026 17:17
@Tisho99 Tisho99 marked this pull request as ready for review June 3, 2026 07:09
@Tisho99 Tisho99 marked this pull request as draft June 4, 2026 07:26
@Tisho99 Tisho99 marked this pull request as ready for review June 4, 2026 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:sale_order_invoice_amount Module sale_order_invoice_amount series:16.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants