From ec174aa7d98b823b973a93cb3a6f1d58fa54d7c7 Mon Sep 17 00:00:00 2001 From: Lorenzo Battistini Date: Thu, 15 Nov 2018 20:30:21 +0100 Subject: [PATCH] FIX (#1) File "/home/elbati/workspace/odoo/instances/odoo11/parts/l10n-italy/l10n_it_split_payment/models/account.py", line 105, in action_move_create self._compute_split_payments() File "/home/elbati/workspace/odoo/instances/odoo11/parts/l10n-italy/l10n_it_split_payment/models/account.py", line 80, in _compute_split_payments ) / inv_total ZeroDivisionError: float division by zero --- l10n_it_split_payment/models/account.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/l10n_it_split_payment/models/account.py b/l10n_it_split_payment/models/account.py index 1e26c4c471c7..6177a8c73a45 100644 --- a/l10n_it_split_payment/models/account.py +++ b/l10n_it_split_payment/models/account.py @@ -75,17 +75,23 @@ def _compute_split_payments(self): for receivable_line in move_line_pool.browse(receivable_line_ids): inv_total = invoice.amount_sp + invoice.amount_total if invoice.type == 'out_invoice': - receivable_line_amount = ( - invoice.amount_total * receivable_line.debit - ) / inv_total + if inv_total: + receivable_line_amount = ( + invoice.amount_total * receivable_line.debit + ) / inv_total + else: + receivable_line_amount = 0 receivable_line.with_context( check_move_validity=False ).write( {'debit': receivable_line_amount}) elif invoice.type == 'out_refund': - receivable_line_amount = ( - invoice.amount_total * receivable_line.credit - ) / inv_total + if inv_total: + receivable_line_amount = ( + invoice.amount_total * receivable_line.credit + ) / inv_total + else: + receivable_line_amount = 0 receivable_line.with_context( check_move_validity=False ).write(