[FIX] account: bugfixed the fiscalyear closing wizard:

* wizard wasn't working if there weren't entries to report: uneeded error was raised
	* wizard wasn't reconciling the reported entries of the new fiscalyear (but of the old fiscalyear)

bzr revid: qdp@cyan-20090917131616-hy6kdupx5j0em41q
This commit is contained in:
Quentin De Paoli 2009-09-17 15:16:16 +02:00
parent 6d6bc82fca
commit fcf202751d
1 changed files with 12 additions and 9 deletions

View File

@ -192,21 +192,24 @@ def _data_save(self, cr, uid, data, context):
})
pool.get('account.move.line').create(cr, uid, move)
offset += limit
ids = pool.get('account.move.line').search(cr, uid, [('journal_id','=',new_journal.id),
('period_id.fiscalyear_id','=',old_fyear.id)])
('period_id.fiscalyear_id','=',new_fyear.id)])
context['fy_closing'] = True
if not ids:
raise wizard.except_wizard(_('UserError'),
_('The old fiscal year does not have any entry to reconcile!'))
pool.get('account.move.line').reconcile(cr, uid, ids, context=context)
if ids:
pool.get('account.move.line').reconcile(cr, uid, ids, context=context)
new_period = data['form']['period_id']
ids = pool.get('account.journal.period').search(cr, uid, [('journal_id','=',new_journal.id),('period_id','=',new_period)])
if ids:
cr.execute('UPDATE account_fiscalyear ' \
if not ids:
ids = [pool.get('account.journal.period').create(cr, uid, {
'name': (new_journal.name or '')+':'+(period.code or ''),
'journal_id': new_journal.id,
'period_id': period.id
})]
cr.execute('UPDATE account_fiscalyear ' \
'SET end_journal_period_id = %s ' \
'WHERE id = %s', (ids[0], new_fyear.id))
'WHERE id = %s', (ids[0], old_fyear.id))
return {}
class wiz_journal_close(wizard.interface):