diff --git a/account_constraints/__openerp__.py b/account_constraints/__openerp__.py index 80009f2bb..60ef18bd1 100644 --- a/account_constraints/__openerp__.py +++ b/account_constraints/__openerp__.py @@ -19,7 +19,7 @@ ############################################################################## { 'name' : 'Account Constraints', - 'version' : '1.0', + 'version' : '1.1', 'depends' : [ 'account', ], @@ -37,7 +37,7 @@ and legal state of the art in other software. Summary of constraints are: * Add a constraint on account move: you cannot pickup a date that is not - in the fiscal year of the concerned period + in the fiscal year of the concerned period (configurable per journal) * For manual entries when multicurrency: @@ -56,8 +56,13 @@ Summary of constraints are: that the user cannot make mistakes even in draft state, he must pass through the parent object to make his modification. + Contributors + * Stéphane Bidoul + """, 'website': 'http://www.camptocamp.com', - 'data': [], + 'data': [ + 'view/account_journal.xml', + ], 'installable': True, } diff --git a/account_constraints/account_constraints.py b/account_constraints/account_constraints.py index bd20e27a3..d5d16f655 100644 --- a/account_constraints/account_constraints.py +++ b/account_constraints/account_constraints.py @@ -22,15 +22,32 @@ from openerp.osv import fields, orm, osv from openerp.tools.translate import _ +class AccountJournal(orm.Model): + _inherit = 'account.journal' + + _columns = { + 'allow_date_fy': fields.boolean('Check Date in Fiscal Year', + help='If set to True then do not ' + 'accept the entry if ' + 'the entry date is not into ' + 'the fiscal year dates'), + } + + _defaults = { + 'allow_date_fy': True, + } + + class AccountMove(orm.Model): _inherit = "account.move" def _check_fiscal_year(self, cr, uid, ids): for move in self.browse(cr, uid, ids): - date_start = move.period_id.fiscalyear_id.date_start - date_stop = move.period_id.fiscalyear_id.date_stop - if not date_start <= move.date <= date_stop: - return False + if move.journal_id.allow_date_fy: + date_start = move.period_id.fiscalyear_id.date_start + date_stop = move.period_id.fiscalyear_id.date_stop + if not date_start <= move.date <= date_stop: + return False return True _constraints = [ diff --git a/account_constraints/view/account_journal.xml b/account_constraints/view/account_journal.xml new file mode 100644 index 000000000..0185aca6f --- /dev/null +++ b/account_constraints/view/account_journal.xml @@ -0,0 +1,18 @@ + + + + + account.journal.allow_date_fy + account.journal + + + + + + + + + + + + \ No newline at end of file