[FIX] pos: fixed crash when canceling a cash register without statement lines (set...
authorThibault Delavallée <tde@openerp.com>
Thu, 9 Feb 2012 14:34:39 +0000 (15:34 +0100)
committerThibault Delavallée <tde@openerp.com>
Thu, 9 Feb 2012 14:34:39 +0000 (15:34 +0100)
bzr revid: tde@openerp.com-20120209143439-puek6acg29g7j53i

addons/account_bank_statement_extensions/account_bank_statement.py

index 3fef72f..507590b 100644 (file)
@@ -50,9 +50,10 @@ class account_bank_statement(osv.osv):
     def button_cancel(self, cr, uid, ids, context=None):
         super(account_bank_statement, self).button_cancel(cr, uid, ids, context=context)
         for st in self.browse(cr, uid, ids, context=context):
-            cr.execute("UPDATE account_bank_statement_line  \
-                SET state='draft' WHERE id in %s ",
-                (tuple([x.id for x in st.line_ids]),))
+            if len(st.line_ids) > 0:
+                cr.execute("UPDATE account_bank_statement_line  \
+                    SET state='draft' WHERE id in %s ",
+                    (tuple([x.id for x in st.line_ids]),))
         return True
 
 account_bank_statement()