summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGoffin Simon <sig@odoo.com>2017-09-25 10:50:39 +0200
committerGoffin Simon <sig@odoo.com>2017-09-25 15:35:59 +0200
commitde95e6f4a820b4aa46d4edfa2d666ea782712cb3 (patch)
tree9937fcfc310af7cafe8a4b5f06c62fef14bd2b02
parentc8796d45feca8659a477c8abbbcc0c7500345226 (diff)
[FIX] account_asset: float division by zero
The number of depreciations or the period length of your asset category cannot be null. opw:773790
-rw-r--r--addons/account_asset/i18n/account_asset.pot6
-rw-r--r--addons/account_asset/models/account_invoice.py2
2 files changed, 8 insertions, 0 deletions
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
@@ -939,6 +939,12 @@ 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.<br/>\n"
" This will generate journal entries for all related installment lines on this period of asset/revenue recognition as well."
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