From e30a5a11a5fc3fabc1cd5102d12248f9fe0a396c Mon Sep 17 00:00:00 2001 From: Ravi Gohil Date: Thu, 31 Jul 2014 15:40:27 +0530 Subject: [PATCH] [FIX] account: avoid closing fiscalyear with unpost entries As when closing fiscal periods, forbid to close a fiscal year with unposted entries. Fixes #1194, opw 610784 --- addons/account/wizard/account_fiscalyear_close_state.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/addons/account/wizard/account_fiscalyear_close_state.py b/addons/account/wizard/account_fiscalyear_close_state.py index 746f1c47976..eb12db1cf4e 100644 --- a/addons/account/wizard/account_fiscalyear_close_state.py +++ b/addons/account/wizard/account_fiscalyear_close_state.py @@ -41,9 +41,15 @@ class account_fiscalyear_close_state(osv.osv_memory): @param ids: List of Account fiscalyear close state’s IDs """ + account_move_obj = self.pool.get('account.move') + for data in self.read(cr, uid, ids, context=context): fy_id = data['fy_id'][0] + account_move_ids = account_move_obj.search(cr, uid, [('period_id.fiscalyear_id', '=', fy_id), ('state', '=', "draft")], context=context) + if account_move_ids: + raise osv.except_osv(_('Invalid Action!'), _('In order to close a fiscalyear, you must first post related journal entries.')) + cr.execute('UPDATE account_journal_period ' \ 'SET state = %s ' \ 'WHERE period_id IN (SELECT id FROM account_period \