[FIX]: allow sach statement to be generaed once
authorMantavya Gajjar <mga@tinyerp.com>
Mon, 2 Aug 2010 18:57:44 +0000 (00:27 +0530)
committerMantavya Gajjar <mga@tinyerp.com>
Mon, 2 Aug 2010 18:57:44 +0000 (00:27 +0530)
bzr revid: mga@tinyerp.com-20100802185744-behoj7gouu82ku0m

addons/account/account_cash_statement.py

index e36521d..815f353 100644 (file)
@@ -309,11 +309,16 @@ class account_cash_statement(osv.osv):
         statement_pool = self.pool.get('account.bank.statement')
 
         statement = statement_pool.browse(cr, uid, ids[0])
+        vals = {}
         
         if not self._user_allow(cr, uid, ids, statement, context={}):
             raise osv.except_osv(_('Error !'), _('User %s does not have rights to access %s journal !' % (statement.user_id.name, statement.journal_id.name)))
         
-        number = self.pool.get('ir.sequence').get(cr, uid, 'account.cash.statement')
+        if statement.name and statement.name == '/':
+            number = self.pool.get('ir.sequence').get(cr, uid, 'account.cash.statement')
+            vals.update({
+                'name':number
+            })
         
 #        if len(statement.starting_details_ids) > 0:
 #            sid = []
@@ -335,11 +340,11 @@ class account_cash_statement(osv.osv):
 #                }
 #                cash_pool.copy(cr, uid, sid, default)
 #            
-        vals = {
+        vals.update({
             'date':time.strftime("%Y-%m-%d %H:%M:%S"), 
             'state':'open',
-            'name':number
-        }
+            
+        })
         
         self.write(cr, uid, ids, vals)
         return True