[FIX] l10n_sa_edi: display correct currency rate
Currently, attempting to print an unconfirmed Saudi invoice in foreign currency results in an error. Furthermore, even if the invoice is confirmed, the exchange rate displayed is not correct, the rate of the confirmation date is used, instead of the accounting date. Steps to reproduce ------------------ * install `l10n_sa_edi` * switch to a Saudi company * create an invoice in a foreign currency. * without confirming the invoice, attempt to print it You should be met with a traceback: `Undefined Function: operator does not exist: date <= boolean` * confirm the invoice, ensuring the confirmation and invoice dates have different currency rates. * print the confirmed invoice.* print the invoice You should see that the printed rate does not align with the actual transaction amounts. Cause ----- The system incorrectly uses the `l10n_sa_confirmation_datetime` to calculate and display the currency rate on the PDF. This field is only populated upon invoice confirmation, leading to errors when printing unconfirmed invoices. Moreover, using this date for confirmed invoices results in displaying an incorrect rate, as it may differ from the `invoice_date`, which should be used for accurate rate calculations. opw-3731624 closes odoo/odoo#159698 X-original-commit: 67da9437d3606cb8a291c071214cc30914ce7fb0 Signed-off-by: Brice Bartoletti (bib) <bib@odoo.com> Signed-off-by: Séna Serge Nshimiyimana (sesn) <sesn@odoo.com>
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
<div t-if="o.company_id.country_id.code == 'SA' and o.currency_id != o.company_id.currency_id"
|
||||
id="sar_amounts" class="row clearfix ms-auto my-3 text-nowrap table">
|
||||
<t t-set="sar_rate"
|
||||
t-value="o.env['res.currency']._get_conversion_rate(o.currency_id, o.company_id.currency_id, o.company_id, o.l10n_sa_confirmation_datetime)"/>
|
||||
t-value="o.env['res.currency']._get_conversion_rate(o.currency_id, o.company_id.currency_id, o.company_id, o.invoice_date)"/>
|
||||
<div name="exchange_rate" class="col-auto">
|
||||
<strong>Exchange Rate</strong>
|
||||
<p class="m-0" t-esc="sar_rate" t-options='{"widget": "float", "precision": 5}'/>
|
||||
@@ -22,7 +22,7 @@
|
||||
<div name="sar_vat_amount" class="col-auto">
|
||||
<strong>VAT Amount (SAR)</strong>
|
||||
<p class="m-0"
|
||||
t-esc="o.currency_id._convert(o.amount_tax, o.company_id.currency_id, o.company_id, o.l10n_sa_confirmation_datetime)"
|
||||
t-esc="o.currency_id._convert(o.amount_tax, o.company_id.currency_id, o.company_id, o.invoice_date)"
|
||||
t-options='{"widget": "monetary", "display_currency": o.company_currency_id}'/>
|
||||
</div>
|
||||
<div name="sar_total" class="col-auto">
|
||||
|
||||
Reference in New Issue
Block a user