[FIX] pass the context to check method of 'ir.model.access'
bzr revid: christophe@tinyerp.com-20090810162409-jhl8imt25vw92mmy
This commit is contained in:
@@ -25,7 +25,7 @@ from osv.orm import except_orm
|
||||
import tools
|
||||
|
||||
class ir_attachment(osv.osv):
|
||||
def check(self, cr, uid, ids, mode):
|
||||
def check(self, cr, uid, ids, mode, context=None):
|
||||
if not ids:
|
||||
return
|
||||
ima = self.pool.get('ir.model.access')
|
||||
@@ -34,7 +34,7 @@ class ir_attachment(osv.osv):
|
||||
cr.execute('select distinct res_model from ir_attachment where id in ('+','.join(map(str, ids))+')')
|
||||
for obj in cr.fetchall():
|
||||
if obj[0]:
|
||||
ima.check(cr, uid, obj[0], mode)
|
||||
ima.check(cr, uid, obj[0], mode, context=context)
|
||||
|
||||
def search(self, cr, uid, args, offset=0, limit=None, order=None,
|
||||
context=None, count=False):
|
||||
@@ -52,7 +52,7 @@ class ir_attachment(osv.osv):
|
||||
if m['res_model']:
|
||||
if m['res_model'] not in cache:
|
||||
cache[m['res_model']] = ima.check(cr, uid, m['res_model'], 'read',
|
||||
raise_exception=False)
|
||||
raise_exception=False, context=context)
|
||||
if not cache[m['res_model']]:
|
||||
ids.remove(m['id'])
|
||||
|
||||
@@ -60,26 +60,26 @@ class ir_attachment(osv.osv):
|
||||
return len(ids)
|
||||
return ids
|
||||
|
||||
def read(self, cr, uid, ids, *args, **kwargs):
|
||||
self.check(cr, uid, ids, 'read')
|
||||
return super(ir_attachment, self).read(cr, uid, ids, *args, **kwargs)
|
||||
def read(self, cr, uid, ids, fields_to_read=None, context=None, load='_classic_read'):
|
||||
self.check(cr, uid, ids, 'read', context=context)
|
||||
return super(ir_attachment, self).read(cr, uid, ids, fields_to_read, context, load)
|
||||
|
||||
def write(self, cr, uid, ids, *args, **kwargs):
|
||||
self.check(cr, uid, ids, 'write')
|
||||
return super(ir_attachment, self).write(cr, uid, ids, *args, **kwargs)
|
||||
def write(self, cr, uid, ids, vals, context=None):
|
||||
self.check(cr, uid, ids, 'write', context=context)
|
||||
return super(ir_attachment, self).write(cr, uid, ids, vals, context)
|
||||
|
||||
def copy(self, cr, uid, id, *args, **kwargs):
|
||||
self.check(cr, uid, [id], 'write')
|
||||
return super(ir_attachment, self).copy(cr, uid, id, *args, **kwargs)
|
||||
def copy(self, cr, uid, id, default=None, context=None):
|
||||
self.check(cr, uid, [id], 'write', context=context)
|
||||
return super(ir_attachment, self).copy(cr, uid, id, default, context)
|
||||
|
||||
def unlink(self, cr, uid, ids, *args, **kwargs):
|
||||
self.check(cr, uid, ids, 'unlink')
|
||||
return super(ir_attachment, self).unlink(cr, uid, ids, *args, **kwargs)
|
||||
def unlink(self, cr, uid, ids, context=None):
|
||||
self.check(cr, uid, ids, 'unlink', context=context)
|
||||
return super(ir_attachment, self).unlink(cr, uid, ids, context)
|
||||
|
||||
def create(self, cr, uid, values, *args, **kwargs):
|
||||
def create(self, cr, uid, values, context=None):
|
||||
if 'res_model' in values and values['res_model'] != '':
|
||||
self.pool.get('ir.model.access').check(cr, uid, values['res_model'], 'create')
|
||||
return super(ir_attachment, self).create(cr, uid, values, *args, **kwargs)
|
||||
self.pool.get('ir.model.access').check(cr, uid, values['res_model'], 'create', context=context)
|
||||
return super(ir_attachment, self).create(cr, uid, values, context)
|
||||
|
||||
def action_get(self, cr, uid, context=None):
|
||||
dataobj = self.pool.get('ir.model.data')
|
||||
|
||||
@@ -316,7 +316,7 @@ class ir_model_access(osv.osv):
|
||||
# pass no groups -> no access
|
||||
return False
|
||||
|
||||
def check(self, cr, uid, model, mode='read', raise_exception=True):
|
||||
def check(self, cr, uid, model, mode='read', raise_exception=True, context=None):
|
||||
if uid==1:
|
||||
# User root have all accesses
|
||||
# TODO: exclude xml-rpc requests
|
||||
|
||||
+7
-7
@@ -1315,7 +1315,7 @@ class orm_template(object):
|
||||
def read_string(self, cr, uid, id, langs, fields=None, context=None):
|
||||
res = {}
|
||||
res2 = {}
|
||||
self.pool.get('ir.model.access').check(cr, uid, 'ir.translation', 'read')
|
||||
self.pool.get('ir.model.access').check(cr, uid, 'ir.translation', 'read', context=context)
|
||||
if not fields:
|
||||
fields = self._columns.keys() + self._inherit_fields.keys()
|
||||
for lang in langs:
|
||||
@@ -1338,7 +1338,7 @@ class orm_template(object):
|
||||
return res
|
||||
|
||||
def write_string(self, cr, uid, id, langs, vals, context=None):
|
||||
self.pool.get('ir.model.access').check(cr, uid, 'ir.translation', 'write')
|
||||
self.pool.get('ir.model.access').check(cr, uid, 'ir.translation', 'write', context=context)
|
||||
for lang in langs:
|
||||
for field in vals:
|
||||
if field in self._columns:
|
||||
@@ -2039,13 +2039,13 @@ class orm(orm_template):
|
||||
self._inherits_reload_src()
|
||||
|
||||
def fields_get(self, cr, user, fields=None, context=None):
|
||||
read_access = self.pool.get('ir.model.access').check(cr, user, self._name, 'write', raise_exception=False)
|
||||
read_access = self.pool.get('ir.model.access').check(cr, user, self._name, 'write', raise_exception=False, context=context)
|
||||
return super(orm, self).fields_get(cr, user, fields, context, read_access)
|
||||
|
||||
def read(self, cr, user, ids, fields=None, context=None, load='_classic_read'):
|
||||
if not context:
|
||||
context = {}
|
||||
self.pool.get('ir.model.access').check(cr, user, self._name, 'read')
|
||||
self.pool.get('ir.model.access').check(cr, user, self._name, 'read', context=context)
|
||||
if not fields:
|
||||
fields = self._columns.keys() + self._inherit_fields.keys()
|
||||
select = ids
|
||||
@@ -2260,7 +2260,7 @@ class orm(orm_template):
|
||||
|
||||
self._check_concurrency(cr, ids, context)
|
||||
|
||||
self.pool.get('ir.model.access').check(cr, uid, self._name, 'unlink')
|
||||
self.pool.get('ir.model.access').check(cr, uid, self._name, 'unlink', context=context)
|
||||
|
||||
properties = self.pool.get('ir.property')
|
||||
domain = [('res_id', '=', False),
|
||||
@@ -2353,7 +2353,7 @@ class orm(orm_template):
|
||||
|
||||
self._check_concurrency(cr, ids, context)
|
||||
|
||||
self.pool.get('ir.model.access').check(cr, user, self._name, 'write')
|
||||
self.pool.get('ir.model.access').check(cr, user, self._name, 'write', context=context)
|
||||
|
||||
upd0 = []
|
||||
upd1 = []
|
||||
@@ -2524,7 +2524,7 @@ class orm(orm_template):
|
||||
"""
|
||||
if not context:
|
||||
context = {}
|
||||
self.pool.get('ir.model.access').check(cr, user, self._name, 'create')
|
||||
self.pool.get('ir.model.access').check(cr, user, self._name, 'create', context=context)
|
||||
|
||||
default = []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user