diff --git a/asset.py b/asset.py
index 1494c22345..bc0f8d1de1 100644
--- a/asset.py
+++ b/asset.py
@@ -19,6 +19,8 @@ from trytond.wizard import (Wizard, StateView, StateTransition, StateReport,
from trytond.tools import grouped_slice
from trytond.modules.company import CompanyReport
+from .exceptions import PrintDepreciationTableError
+
def date2datetime(date):
return datetime.datetime.combine(date, datetime.time())
@@ -928,8 +930,8 @@ class AssetDepreciationTable(CompanyReport):
__name__ = 'account.asset.depreciation_table'
@classmethod
- def get_context(cls, records, data):
- context = super(AssetDepreciationTable, cls).get_context(records, data)
+ def get_context(cls, records, header, data):
+ context = super().get_context(records, header, data)
AssetDepreciation = cls.get_asset_depreciation()
AssetDepreciation.start_date = data['start_date']
@@ -1120,6 +1122,9 @@ class PrintDepreciationTable(Wizard):
('end_date', '>', self.start.start_date),
('state', '!=', 'draft'),
])
+ if not assets:
+ raise PrintDepreciationTableError(
+ gettext('account_asset.msg_no_assets'))
return action, {
'ids': [a.id for a in assets],
'start_date': self.start.start_date,
diff --git a/exceptions.py b/exceptions.py
new file mode 100644
index 0000000000..d3db29109c
--- /dev/null
+++ b/exceptions.py
@@ -0,0 +1,8 @@
+# This file is part of Tryton. The COPYRIGHT file at the top level of
+# this repository contains the full copyright notices and license terms.
+
+from trytond.exceptions import UserError
+
+
+class PrintDepreciationTableError(UserError):
+ pass
diff --git a/message.xml b/message.xml
index 08774d3c84..27301758a2 100644
--- a/message.xml
+++ b/message.xml
@@ -18,5 +18,8 @@ this repository contains the full copyright notices and license terms. -->
Asset can be used only once on invoice line.
+
+ There is no started asset.
+