[FIX] account: put a restriction to re-open a period which belongs to
authorRifakat <rha@tinyerp.com>
Wed, 23 Jan 2013 10:11:30 +0000 (15:41 +0530)
committerChris Biersbach <cbi@openerp.com>
Wed, 23 Jan 2013 10:11:30 +0000 (15:41 +0530)
the closed fiscal year,
it must not be possible to re-open a period and post journal items when its fiscal year is closed

bzr revid: rha@tinyerp.com-20130123101130-yiun5oku3h0prbdy

addons/account/account.py

index f9b1ff3..8a1ca87 100644 (file)
@@ -1059,6 +1059,9 @@ class account_period(osv.osv):
 
     def action_draft(self, cr, uid, ids, *args):
         mode = 'draft'
+        for period in self.browse(cr, uid, ids):
+            if period.fiscalyear_id.state == 'done':
+                raise osv.except_osv(_('Warning !'), _('You can not re-open a period which belongs to closed fiscal year'))
         cr.execute('update account_journal_period set state=%s where period_id in %s', (mode, tuple(ids),))
         cr.execute('update account_period set state=%s where id in %s', (mode, tuple(ids),))
         return True