[FIX] l10n_gcc_invoice: prevent trace back while printing an invoice

'ZeroDivisionError: float division by zero' is generated if the user prints
an invoice pdf without including an invoice line or invoice line with the
product price 0.

Steps to Reproduce

- Install the 'l10n_gcc_invoice' modules.
- Go to the current company and change the country to any Gulf nation, such
as Bahrain, Kuwait, Oman, Qatar, Saudi Arabia, or the United Arab Emirates if
it isn't already.
- Go to Accounting > Configuration > Accounting > Currencies
- Activate another currency.
- Open an 'Invoices' module
- Add the 'currency_id' field in the invoice form view.
- Create a new invoice except including the invoice line or invoice line with
 product price 0 and select a currency that does not equal the current company
currency.
- And print this invoice.

Applying this commit will resolve this issue.

sentry-4210558233

closes odoo/odoo#125502

X-original-commit: ae9de44b91b7e80b4a44d69afa69ca95d8f528fe
Signed-off-by: Quentin De Paoli <qdp@odoo.com>
Signed-off-by: Josse Colpaert <jco@odoo.com>
This commit is contained in:
mega-odoo
2023-06-22 15:41:03 +02:00
parent 7416acc111
commit c5290e5427
@@ -450,7 +450,7 @@
<div t-if="o.currency_id != o.company_id.currency_id"
class="row clearfix ms-auto text-nowrap border-top border-bottom p-2">
<t t-set="exchange_rate"
t-value="abs(o.amount_total_signed) / o.amount_total"/>
t-value="abs(o.amount_total_signed) / o.amount_total if o.amount_total else 0"/>
<div name="exchange_rate" t-attf-class="#{'col-auto col-3 mw-100' if report_type != 'html' else 'col'}">
<strong>سعر الصرف</strong><br/>
<strong>Exchange Rate</strong>