[FIX] account: improved code
authorRifakat <rha@tinyerp.com>
Tue, 26 Mar 2013 10:12:44 +0000 (15:42 +0530)
committerRifakat <rha@tinyerp.com>
Tue, 26 Mar 2013 10:12:44 +0000 (15:42 +0530)
bzr revid: rha@tinyerp.com-20130326101244-myggbw6rlqazh9h5

1  2 
addons/account/account.py

@@@ -926,9 -926,12 +926,11 @@@ class account_period(osv.osv)
  
      def action_draft(self, cr, uid, ids, *args):
          mode = 'draft'
--        for id in ids:
-             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))
 -            period = self.browse(cr, uid, id)
++        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=%s', (mode, id))
 -            cr.execute('update account_period set state=%s where id=%s', (mode, id))
++        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
  
      def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=100):