KERNEL: add check if all id exist and add search_count from ame
bzr revid: ced-2323d89a2163f9218413615befdce0400441eb67
This commit is contained in:
+22
-1
@@ -912,6 +912,10 @@ class orm(object):
|
||||
cr.execute('SELECT id FROM '+self._table+' WHERE id IN ('+ids_str+')'+d1, d2)
|
||||
if not cr.rowcount == len({}.fromkeys(ids)):
|
||||
raise except_orm('AccessError', 'You try to bypass an access rule (Document type: %s).'%self._description)
|
||||
else:
|
||||
cr.execute('SELECT id FROM '+self._table+' WHERE id IN ('+ids_str+')')
|
||||
if not cr.rowcount == len({}.fromkeys(ids)):
|
||||
raise except_orm('AccessError', 'You try to write on an record that doesn\'t exist (Document type: %s).'%self._description)
|
||||
cr.execute('update '+self._table+' set '+string.join(upd0,',')+' where id in ('+ids_str+')'+d1, upd1+ d2)
|
||||
|
||||
if totranslate:
|
||||
@@ -1517,8 +1521,25 @@ class orm(object):
|
||||
return (qu1,qu2,tables)
|
||||
|
||||
def search_count(self, cr, user, args, context={}):
|
||||
return 128
|
||||
# compute the count of records
|
||||
(qu1,qu2,tables) = self._where_calc(cr, user, args, context)
|
||||
|
||||
if len(qu1):
|
||||
qu1 = ' where '+string.join(qu1,' and ')
|
||||
else:
|
||||
qu1 = ''
|
||||
|
||||
# construct a clause for the rules :
|
||||
d1, d2 = self.pool.get('ir.rule').domain_get(cr, user, self._name)
|
||||
if d1:
|
||||
qu1 = qu1 and qu1+' and '+d1 or ' where '+d1
|
||||
qu2 += d2
|
||||
|
||||
# execute the "main" query to fetch the count of ids
|
||||
cr.execute('select count(%s.id) from ' % self._table + ','.join(tables) +qu1, qu2)
|
||||
res = cr.fetchall()
|
||||
return res[0][0]
|
||||
|
||||
def search(self, cr, user, args, offset=0, limit=None, order=None, context={}):
|
||||
|
||||
# compute the where, order by, limit and offset clauses
|
||||
|
||||
Reference in New Issue
Block a user