[FIX] Division by zero in computation of accessory costs

This commit is contained in:
Alexis de Lattre
2018-12-04 14:17:20 +01:00
parent 59b1959ba6
commit 291cf20b32

View File

@@ -428,13 +428,18 @@ class IntrastatProductDeclaration(models.Model):
total_inv_accessory_costs_cc *
ac_line_vals['amount_company_currency'] /
total_inv_product_cc)
else:
elif total_inv_weight:
# pro-rata of the weight
for ac_line_vals in lines_current_invoice:
ac_line_vals['amount_accessory_cost_company_currency'] = (
total_inv_accessory_costs_cc *
ac_line_vals['weight'] /
total_inv_weight)
else:
for ac_line_vals in lines_current_invoice:
ac_line_vals['amount_accessory_cost_company_currency'] = (
total_inv_accessory_costs_cc /
len(lines_current_invoice))
def _prepare_invoice_domain(self):
"""