[IMP]: Improve the exist() method in orm_memory and orm_template (Ref: Case 17622)
authorskh <skh@tinyerp.com>
Wed, 21 Sep 2011 13:12:06 +0000 (18:42 +0530)
committerskh <skh@tinyerp.com>
Wed, 21 Sep 2011 13:12:06 +0000 (18:42 +0530)
bzr revid: skh@tinyerp.com-20110921131206-5d4q91wmtvamkki5

bin/osv/orm.py

index 7fe1d75..ead0d5b 100644 (file)
@@ -1814,7 +1814,7 @@ class orm_template(object):
     def copy(self, cr, uid, id, default=None, context=None):
         raise NotImplementedError(_('The copy method is not implemented on this object !'))
 
-    def exists(self, cr, uid, id, context=None):
+    def exists(self, cr, uid, ids, context=None):
         raise NotImplementedError(_('The exists method is not implemented on this object !'))
 
     def read_string(self, cr, uid, id, langs, fields=None, context=None):
@@ -2112,8 +2112,10 @@ class orm_memory(orm_template):
         # nothing to check in memory...
         pass
 
-    def exists(self, cr, uid, id, context=None):
-        return id in self.datas
+    def exists(self, cr, uid, ids, context=None):
+        if isinstance(ids, (int,long)):
+            ids = [ids]
+        return all(( id in self.datas for id in ids ))
 
 class orm(orm_template):
     _sql_constraints = []