solved error of no period_ids and misc. changes in wizard_fiscalyear_close.py
authorJay Vora <jvo@tinyerp.com>
Mon, 28 Jul 2008 13:49:04 +0000 (19:19 +0530)
committerJay Vora <jvo@tinyerp.com>
Mon, 28 Jul 2008 13:49:04 +0000 (19:19 +0530)
bzr revid: jvo@tinyerp.com-20080728134904-jya4666cek62lau2

addons/account/wizard/wizard_fiscalyear_close.py

index 490473a..866f7f6 100644 (file)
@@ -58,17 +58,21 @@ def _data_load(self, cr, uid, data, context):
 
 def _data_save(self, cr, uid, data, context):
        if not data['form']['sure']:
-               raise wizard.except_wizard(_('UserError'), _('Closing of fiscal year canceled, please check the box !'))
+               raise wizard.except_wizard(_('UserError'), _('Closing of fiscal year cancelled, please check the box !'))
        pool = pooler.get_pool(cr.dbname)
 
        fy_id = data['form']['fy_id']
        if data['form']['report_new']:
-               period = pool.get('account.fiscalyear').browse(cr, uid, data['form']['fy2_id']).period_ids[0]
+               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'))
+                                               _('The new fiscal year should have a journal for new entries defined on it.'))
 
                new_journal = start_jp.journal_id