[FIX] account_asset: float division by zero

The number of depreciations or the period length of your asset category cannot be null.

opw:773790
This commit is contained in:
Goffin Simon
2017-09-25 15:35:59 +02:00
parent c8796d45fe
commit de95e6f4a8
2 changed files with 8 additions and 0 deletions
@@ -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.<br/>\n"
@@ -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