[REF] orm:
- isinstance(ids, dict) is done at the end, but not at the beginning, so if ids was a single dict, it would break in the map(lambda). - The loop to convert None to False can be done in _read_flat instead of read (there is already plenty of loops in _read_flat) - The __getattr__ was breaking the stacktrace. bzr revid: vmt@openerp.com-20130314154418-0wmxfw1ot92kjmzf
This commit is contained in:
parent
a4926b070b
commit
c79c23d26e
|
@ -480,7 +480,9 @@ class browse_record(object):
|
|||
try:
|
||||
return self[name]
|
||||
except KeyError, e:
|
||||
raise AttributeError(e)
|
||||
import sys
|
||||
exc_info = sys.exc_info()
|
||||
raise AttributeError, "Got %r while trying to get attribute `%s`." % (e, name), exc_info[2]
|
||||
|
||||
def __contains__(self, name):
|
||||
return (name in self._table._columns) or (name in self._table._inherit_fields) or hasattr(self._table, name)
|
||||
|
@ -3589,8 +3591,6 @@ class BaseModel(object):
|
|||
|
||||
"""
|
||||
|
||||
if not context:
|
||||
context = {}
|
||||
self.check_access_rights(cr, user, 'read')
|
||||
fields = self.check_field_access_rights(cr, user, 'read', fields)
|
||||
if isinstance(ids, (int, long)):
|
||||
|
@ -3600,12 +3600,7 @@ class BaseModel(object):
|
|||
select = map(lambda x: isinstance(x, dict) and x['id'] or x, select)
|
||||
result = self._read_flat(cr, user, select, fields, context, load)
|
||||
|
||||
for r in result:
|
||||
for key, v in r.items():
|
||||
if v is None:
|
||||
r[key] = False
|
||||
|
||||
if isinstance(ids, (int, long, dict)):
|
||||
if isinstance(ids, (int, long)):
|
||||
return result and result[0] or False
|
||||
return result
|
||||
|
||||
|
@ -3739,34 +3734,37 @@ class BaseModel(object):
|
|||
if field in self._columns:
|
||||
fobj = self._columns[field]
|
||||
|
||||
if not fobj:
|
||||
continue
|
||||
groups = fobj.read
|
||||
if groups:
|
||||
edit = False
|
||||
for group in groups:
|
||||
module = group.split(".")[0]
|
||||
grp = group.split(".")[1]
|
||||
cr.execute("select count(*) from res_groups_users_rel where gid IN (select res_id from ir_model_data where name=%s and module=%s and model=%s) and uid=%s", \
|
||||
(grp, module, 'res.groups', user))
|
||||
readonly = cr.fetchall()
|
||||
if readonly[0][0] >= 1:
|
||||
edit = True
|
||||
break
|
||||
elif readonly[0][0] == 0:
|
||||
edit = False
|
||||
else:
|
||||
edit = False
|
||||
if fobj:
|
||||
groups = fobj.read
|
||||
if groups:
|
||||
edit = False
|
||||
for group in groups:
|
||||
module = group.split(".")[0]
|
||||
grp = group.split(".")[1]
|
||||
cr.execute("select count(*) from res_groups_users_rel where gid IN (select res_id from ir_model_data where name=%s and module=%s and model=%s) and uid=%s", \
|
||||
(grp, module, 'res.groups', user))
|
||||
readonly = cr.fetchall()
|
||||
if readonly[0][0] >= 1:
|
||||
edit = True
|
||||
break
|
||||
elif readonly[0][0] == 0:
|
||||
edit = False
|
||||
else:
|
||||
edit = False
|
||||
|
||||
if not edit:
|
||||
if type(vals[field]) == type([]):
|
||||
vals[field] = []
|
||||
elif type(vals[field]) == type(0.0):
|
||||
vals[field] = 0
|
||||
elif type(vals[field]) == type(''):
|
||||
vals[field] = '=No Permission='
|
||||
else:
|
||||
vals[field] = False
|
||||
|
||||
if vals[field] is None:
|
||||
vals[field] = False
|
||||
|
||||
if not edit:
|
||||
if type(vals[field]) == type([]):
|
||||
vals[field] = []
|
||||
elif type(vals[field]) == type(0.0):
|
||||
vals[field] = 0
|
||||
elif type(vals[field]) == type(''):
|
||||
vals[field] = '=No Permission='
|
||||
else:
|
||||
vals[field] = False
|
||||
return res
|
||||
|
||||
# TODO check READ access
|
||||
|
|
Loading…
Reference in New Issue