From de95e6f4a820b4aa46d4edfa2d666ea782712cb3 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Mon, 25 Sep 2017 10:50:39 +0200 Subject: [PATCH] [FIX] account_asset: float division by zero The number of depreciations or the period length of your asset category cannot be null. opw:773790 --- addons/account_asset/i18n/account_asset.pot | 6 ++++++ addons/account_asset/models/account_invoice.py | 2 ++ 2 files changed, 8 insertions(+) diff --git a/addons/account_asset/i18n/account_asset.pot b/addons/account_asset/i18n/account_asset.pot index 59277192469..adeab503f19 100644 --- a/addons/account_asset/i18n/account_asset.pot +++ b/addons/account_asset/i18n/account_asset.pot @@ -938,6 +938,12 @@ msgstr "" msgid "The number of depreciations needed to depreciate your asset" msgstr "" +#. module: account_asset +#: code:addons/account_asset/models/account_invoice.py:52 +#, python-format +msgid "The number of depreciations or the period length of your asset category cannot be null." +msgstr "" + #. module: account_asset #: model:ir.ui.view,arch_db:account_asset.view_asset_depreciation_confirmation_wizard msgid "This wizard will post installment/depreciation lines for the selected month.
\n" diff --git a/addons/account_asset/models/account_invoice.py b/addons/account_asset/models/account_invoice.py index a6b65b3425e..5f1c90dcc55 100644 --- a/addons/account_asset/models/account_invoice.py +++ b/addons/account_asset/models/account_invoice.py @@ -48,6 +48,8 @@ class AccountInvoiceLine(models.Model): self.asset_end_date = False cat = self.asset_category_id if cat: + if cat.method_number == 0 or cat.method_period == 0: + raise UserError(_('The number of depreciations or the period length of your asset category cannot be null.')) months = cat.method_number * cat.method_period if self.invoice_id.type in ['out_invoice', 'out_refund']: self.asset_mrr = self.price_subtotal_signed / months