From d6dc5d0fbb44fba580c134a0766b244b87090138 Mon Sep 17 00:00:00 2001 From: "Daniel Kosky (dako)" Date: Tue, 17 Jan 2023 12:07:24 +0000 Subject: [PATCH] [FIX] l10n_ke_edi_tremol: currency rate zero division error When posting an invoice to the fiscal device, the currency rate is calculated from an invoice line by dividing its balance by the lines subtotal. This is because the balance in the database will be in KES (Kenyan shillings), whereas the currency on the line can differ. From v16.0 onwards the way that a line is retrieved in order to calculate the currency rate incorrect. When (for example) an invoice has 'Section' lines, then a division by zero is attempted (resulting in a zero division error). This commit amends the line so that the first line of the previously assigned 'lines' variable is used instead. This variable contains only valid invoice lines (non-zero, non-display type etc). It is already done this way from v15.0 onwards (up to v16.0). closes odoo/odoo#110210 X-original-commit: 4e0374fd095ea5e65e8ce311d133fca066e3ee6a Signed-off-by: Josse Colpaert --- addons/l10n_ke_edi_tremol/models/account_move.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/l10n_ke_edi_tremol/models/account_move.py b/addons/l10n_ke_edi_tremol/models/account_move.py index 3edbd62ff82..8684c90b7be 100644 --- a/addons/l10n_ke_edi_tremol/models/account_move.py +++ b/addons/l10n_ke_edi_tremol/models/account_move.py @@ -142,7 +142,7 @@ class AccountMove(models.Model): if self.currency_id == self.company_id.currency_id: currency_rate = 1 else: - currency_rate = abs(self.invoice_line_ids[0].balance / self.invoice_line_ids[0].price_subtotal) + currency_rate = abs(lines[0].balance / lines[0].price_subtotal) discount_dict = {line.id: line.discount for line in lines if line.price_total > 0} for line in lines: