[FIX]: fix a small problem in voucher for opening a voucher
authorMantavya Gajjar <mga@tinyerp.com>
Sun, 15 Aug 2010 12:48:12 +0000 (18:18 +0530)
committerMantavya Gajjar <mga@tinyerp.com>
Sun, 15 Aug 2010 12:48:12 +0000 (18:18 +0530)
bzr revid: mga@tinyerp.com-20100815124812-2fsaw7y6hznhfxg4

addons/account_voucher/voucher.py

index 7ca65ac..5eff399 100644 (file)
@@ -292,19 +292,29 @@ class account_voucher(osv.osv):
 
         if total != 0:
             res = {
-                'amount':total
+                'amount':total,
+                'state':voucher.state
             }
             self.write(dbcr, uid, ids, res)
         else:
             raise osv.except_osv(_('Invalid amount !'), _('You can not create Pro-Forma voucher with Total amount <= 0 !'))
         return True
-
+    
+    def write(self, cr, uid, ids, vals, context={}):
+        res = super(account_voucher, self).write(cr, uid, ids, vals, context)
+        
+        if not 'state' in vals.keys():
+            self.open_voucher(cr, uid, ids, context)
+        
+        return res
+        
     def voucher_recheck(self, cr, uid, ids, context={}):
-        self.open_voucher(cr, uid, ids, context)
+        #self.open_voucher(cr, uid, ids, context)
         self.write(cr, uid, ids, {'state':'recheck'}, context)
         return True
 
     def proforma_voucher(self, cr, uid, ids, context={}):
+        #self.open_voucher(cr, uid, ids, context)
         self.action_move_line_create(cr, uid, ids)
         self.write(cr, uid, ids, {'state':'posted'})
         return True