Add ir.message and use custom exceptions
issue3672
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
# 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.model.exceptions import ValidationError
|
||||
|
||||
|
||||
class PrintError(ValidationError):
|
||||
pass
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0"?>
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<tryton>
|
||||
<data group="1">
|
||||
<record model="ir.message" id="msg_report_same_fiscalyear">
|
||||
<field name="text">To generate the report the periods must be in the same fiscal year.</field>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
||||
+5
-9
@@ -9,6 +9,7 @@ from sql.aggregate import Count
|
||||
from sql.conditionals import Case
|
||||
from sql.functions import Substring, Position
|
||||
|
||||
from trytond.i18n import gettext
|
||||
from trytond.model import ModelView, fields
|
||||
from trytond.model.modelsql import convert_from
|
||||
from trytond.pool import Pool
|
||||
@@ -17,6 +18,8 @@ from trytond.transaction import Transaction
|
||||
from trytond.wizard import Wizard, StateView, StateTransition, StateReport, \
|
||||
Button
|
||||
|
||||
from .exceptions import PrintError
|
||||
|
||||
__all__ = ['AEAT111', 'AEAT115', 'AEAT303', 'PrintAEATStart', 'PrintAEAT']
|
||||
|
||||
|
||||
@@ -309,14 +312,6 @@ class PrintAEAT(Wizard):
|
||||
model_115 = StateReport('account.reporting.aeat115')
|
||||
model_303 = StateReport('account.reporting.aeat303')
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super().__setup__()
|
||||
cls._error_messages.update({
|
||||
'same_fiscalyear': ("Periods should be of the same fiscalyear "
|
||||
"to generate the report."),
|
||||
})
|
||||
|
||||
def transition_choice(self):
|
||||
validate = getattr(self, 'validate_%s' % self.start.report, None)
|
||||
if validate:
|
||||
@@ -332,4 +327,5 @@ class PrintAEAT(Wizard):
|
||||
|
||||
def validate_303(self):
|
||||
if len(set(p.fiscalyear for p in self.start.periods)) > 1:
|
||||
self.raise_user_error('same_fiscalyear')
|
||||
raise PrintError(
|
||||
gettext('account_es.msg_report_same_fiscalyear'))
|
||||
|
||||
@@ -12,3 +12,4 @@ xml:
|
||||
tax_pyme.xml
|
||||
view.xml
|
||||
reporting_tax.xml
|
||||
message.xml
|
||||
|
||||
Reference in New Issue
Block a user