diff --git a/account.py b/account.py index db34aa3c3c..a0cf5a2591 100644 --- a/account.py +++ b/account.py @@ -172,9 +172,11 @@ class AccountTemplate(OSV): def __init__(self): super(AccountTemplate, self).__init__() self._constraints += [ - ('check_recursion', - 'Error! You can not create recursive accounts.', ['parent']), + ('check_recursion', 'recursive_accounts'), ] + self._error_messages.update({ + 'recursive_accounts': 'You can not create recursive accounts!', + }) self._order.insert(0, ('code', 'ASC')) self._order.insert(1, ('name', 'ASC')) @@ -350,9 +352,11 @@ class Account(OSV): def __init__(self): super(Account, self).__init__() self._constraints += [ - ('check_recursion', - 'Error! You can not create recursive accounts.', ['parent']), + ('check_recursion', 'recursive_accounts'), ] + self._error_messages.update({ + 'recursive_accounts': 'You can not create recursive accounts!', + }) self._order.insert(0, ('code', 'ASC')) self._order.insert(1, ('name', 'ASC')) diff --git a/fiscalyear.py b/fiscalyear.py index dfee6f0406..ae2534ddac 100644 --- a/fiscalyear.py +++ b/fiscalyear.py @@ -38,18 +38,18 @@ class FiscalYear(OSV): 'create_period_3', ] self._constraints += [ - ('check_dates', - 'Error! You can not have 2 fiscal years that overlaps!', - ['start_date', 'end_date']), - ('check_post_move_sequence', - 'Error! You must have different post move sequence ' \ - 'per fiscal year!', ['post_move_sequence']), + ('check_dates', 'fiscalyear_overlaps'), + ('check_post_move_sequence', 'different_post_move_sequence'), ] self._order.insert(0, ('start_date', 'ASC')) self._error_messages.update({ 'change_post_move_sequence': 'You can not change ' \ 'the post move sequence', 'no_fiscalyear_date': 'No fiscal year defined for this date!', + 'fiscalyear_overlaps': + 'You can not have 2 fiscal years that overlaps!', + 'different_post_move_sequence': + 'You must have different post move sequence per fiscal year!', }) def default_state(self, cursor, user, context=None): diff --git a/move.py b/move.py index a01ec69eca..7db0e1ca1d 100644 --- a/move.py +++ b/move.py @@ -41,15 +41,9 @@ class Move(OSV): def __init__(self): super(Move, self).__init__() self._constraints += [ - ('check_centralisation', - 'Error! You can not create more than one move per period \n' \ - 'in centralized journal', ['journal']), - ('check_company', - 'Error! You can not create lines on account \n' \ - 'from different company in the same move!', ['lines']), - ('check_date', - 'Error! You can not create move ' \ - 'with date outside the period!', ['date']), + ('check_centralisation', 'period_centralized_journal'), + ('check_company', 'company_in_move'), + ('check_date', 'date_outside_period'), ] self._rpc_allowed += [ 'button_post', @@ -63,6 +57,13 @@ class Move(OSV): 'post_unbalanced_move': 'You can not post a unbalanced move!', 'modify_posted_move': 'You can not modify a posted move ' \ 'in this journal!', + 'period_centralized_journal': 'You can not create more than ' \ + 'one move per period\n' \ + 'in centralized journal!', + 'company_in_move': 'You can not create lines on account\n' \ + 'from different company in the same move!', + 'date_outside_period': 'You can not create move ' \ + 'with date outside the period!', }) def _auto_init(self, cursor, module_name): @@ -292,13 +293,13 @@ class Reconciliation(OSV): def __init__(self): super(Reconciliation, self).__init__() self._constraints += [ - ('check_lines', 'You can not create reconciliation ' \ - 'where lines are not balanced, nor valid, ' \ - 'nor in the same account, nor in account to reconcile!', - ['lines']), + ('check_lines', 'invalid_reconciliation'), ] self._error_messages.update({ 'modify': 'You can not modify a reconciliation!', + 'invalid_reconciliation': 'You can not create reconciliation ' \ + 'where lines are not balanced, nor valid, ' \ + 'nor in the same account, nor in account to reconcile!', }) def default_name(self, cursor, user, context=None): @@ -406,8 +407,7 @@ class Line(OSV): 'Amount Second Currency must be positive!'), ] self._constraints += [ - ('check_account', 'You can not create move line \n' \ - 'on view/inactive account!', ['account']), + ('check_account', 'move_view_inactive_account'), ] self._rpc_allowed += [ 'on_write', @@ -419,6 +419,8 @@ class Line(OSV): 'modify_posted_move': 'You can not modify line from a posted move!', 'modify_reconciled': 'You can not modify reconciled line!', 'no_journal': 'No journal defined!', + 'move_view_inactive_account': 'You can not create move line\n' \ + 'on view/inactive account!', }) def default_date(self, cursor, user, context=None): diff --git a/period.py b/period.py index e03a7029ba..42af5396eb 100644 --- a/period.py +++ b/period.py @@ -31,12 +31,8 @@ class Period(OSV): def __init__(self): super(Period, self).__init__() self._constraints += [ - ('check_dates', - 'Error! You can not have 2 periods that overlaps!', - ['start_date', 'end_date']), - ('check_post_move_sequence', - 'Error! You must have different post move sequence ' \ - 'per fiscal year!', ['post_move_sequence']), + ('check_dates', 'periods_overlaps'), + ('check_post_move_sequence', 'different_move_sequence'), ] self._order.insert(0, ('start_date', 'ASC')) self._error_messages.update({ @@ -52,6 +48,9 @@ class Period(OSV): 'if there is already posted move in the period', 'close_period_non_posted_move': 'You can not close ' \ 'a period with non posted moves!', + 'periods_overlaps': 'You can not have 2 periods that overlaps!', + 'different_move_sequence': 'You must have different ' \ + 'post move sequence per fiscal year!', }) def default_state(self, cursor, user, context=None): diff --git a/tax.py b/tax.py index 8ac7e29ebc..499c6ca80c 100644 --- a/tax.py +++ b/tax.py @@ -38,9 +38,11 @@ class CodeTemplate(OSV): def __init__(self): super(CodeTemplate, self).__init__() self._constraints += [ - ('check_recursion', - 'Error! You can not create recursive tax code!', ['parent']), + ('check_recursion', 'recursive_tax_code'), ] + self._error_messages.update({ + 'recursive_tax_code': 'You can not create recursive tax code!', + }) self._order.insert(0, ('code', 'ASC')) self._order.insert(0, ('account', 'ASC')) @@ -128,9 +130,11 @@ class Code(OSV): def __init__(self): super(Code, self).__init__() self._constraints += [ - ('check_recursion', - 'Error! You can not create recursive tax code!', ['parent']), + ('check_recursion', 'recursive_tax_code'), ] + self._error_messages.update({ + 'recursive_tax_code': 'You can not create recursive tax code!', + }) self._order.insert(0, ('code', 'ASC')) def default_active(self, cursor, user, context=None):