[FIX] account: put a restriction to re-open a period which belongs to
authorRifakat <rha@tinyerp.com>
Wed, 23 Jan 2013 10:20:48 +0000 (15:50 +0530)
committerRifakat <rha@tinyerp.com>
Wed, 23 Jan 2013 10:20:48 +0000 (15:50 +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-20130123102048-cgxt9qup393vj3nl

addons/account/account.py

index 3db23a2..858bdb7 100644 (file)
@@ -927,6 +927,9 @@ class account_period(osv.osv):
     def action_draft(self, cr, uid, ids, *args):
         mode = 'draft'
         for id in ids:
+            period = self.browse(cr, uid, id)
+            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=%s', (mode, id))
             cr.execute('update account_period set state=%s where id=%s', (mode, id))
         return True