From b2b14e48fef3b3c45ea909176aba657bb1455cc7 Mon Sep 17 00:00:00 2001 From: ced <> Date: Thu, 27 Dec 2007 09:19:53 +0000 Subject: [PATCH] Add constraint on move to check that all lines have the same journal and period than the move bzr revid: ced-580ba2b3f083fdd57a2a62c70fdd65240cae63a8 --- addons/account/account.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/addons/account/account.py b/addons/account/account.py index 7a42315cc49..dfd9e1de9dd 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -618,10 +618,22 @@ class account_move(osv.osv): return False return True + def _check_period_journal(self, cursor, user, ids): + for move in self.browse(cursor, user, ids): + for line in move.line_id: + if line.period_id.id != move.period_id.id: + return False + if line.journal_id.id != move.journal_id.id: + return False + return True + _constraints = [ (_check_centralisation, 'You can not create more than one move per period on centralized journal', ['journal_id']), + (_check_period_journal, + 'You can not create entries on different period/journal in the same move', + ['line_id']), ] def post(self, cr, uid, ids, context=None): if self.validate(cr, uid, ids, context) and len(ids):