From 69e276222efb679980aa01a53fef92f7ea18a045 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Thu, 8 Jan 2009 10:37:58 +0100 Subject: [PATCH] [FIX] fix a bug in the "Close fiscal year wizard" that avoiding to close a fiscal year without creating new entries bzr revid: christophe@tinyerp.com-20090108093758-tf3urqgh8oejhzqk --- addons/account/wizard/wizard_fiscalyear_close.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/addons/account/wizard/wizard_fiscalyear_close.py b/addons/account/wizard/wizard_fiscalyear_close.py index 7dfc86ac5c3..fcb51906f3d 100644 --- a/addons/account/wizard/wizard_fiscalyear_close.py +++ b/addons/account/wizard/wizard_fiscalyear_close.py @@ -55,14 +55,15 @@ def _data_save(self, cr, uid, data, context): pool = pooler.get_pool(cr.dbname) fy_id = data['form']['fy_id'] + new_fyear = pool.get('account.fiscalyear').browse(cr, uid, data['form']['fy2_id']) + start_jp = new_fyear.start_journal_period_id + if data['form']['report_new']: periods_fy2 = pool.get('account.fiscalyear').browse(cr, uid, data['form']['fy2_id']).period_ids if not periods_fy2: raise wizard.except_wizard(_('UserError'), _('There are no periods defined on New Fiscal Year.')) period=periods_fy2[0] - new_fyear = pool.get('account.fiscalyear').browse(cr, uid, data['form']['fy2_id']) - start_jp = new_fyear.start_journal_period_id if not start_jp: raise wizard.except_wizard(_('UserError'), _('The new fiscal year should have a journal for new entries define on it')) @@ -163,7 +164,7 @@ def _data_save(self, cr, uid, data, context): 'WHERE fiscalyear_id = %s', ('done',fy_id)) cr.execute('UPDATE account_fiscalyear ' \ 'SET state = %s, end_journal_period_id = %s' \ - 'WHERE id = %s', ('done',start_jp.id,fy_id)) + 'WHERE id = %s', ('done', start_jp and start_jp.id or None, fy_id)) return {} class wiz_journal_close(wizard.interface):