[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
This commit is contained in:
parent
6d3855e9dc
commit
e30a5a11a5
|
@ -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 \
|
||||
|
|
Loading…
Reference in New Issue