permission, user_default fix
This commit is contained in:
parent
2906be5455
commit
a40d7e15d8
3 changed files with 11 additions and 13 deletions
|
|
@ -134,19 +134,17 @@ class Profile:
|
|||
self.all_read += self.can_read
|
||||
|
||||
def get_defaults(self):
|
||||
"""
|
||||
Get the user's default values based on user and role profile
|
||||
"""
|
||||
roles = self.get_roles() + [self.name]
|
||||
res = webnotes.conn.sql("""select defkey, defvalue
|
||||
from `tabDefaultValue` where parent in ("%s") order by idx""" % '", "'.join(roles))
|
||||
if not self.defaults:
|
||||
roles = self.get_roles() + [self.name]
|
||||
res = webnotes.conn.sql("""select defkey, defvalue
|
||||
from `tabDefaultValue` where parent in ("%s") order by idx""" % '", "'.join(roles))
|
||||
|
||||
self.defaults = {'owner': [self.name], "user": [self.name]}
|
||||
self.defaults = {'owner': [self.name], "user": [self.name]}
|
||||
|
||||
for rec in res:
|
||||
if not self.defaults.has_key(rec[0]):
|
||||
self.defaults[rec[0]] = []
|
||||
self.defaults[rec[0]].append(rec[1] or '')
|
||||
for rec in res:
|
||||
if not self.defaults.has_key(rec[0]):
|
||||
self.defaults[rec[0]] = []
|
||||
self.defaults[rec[0]].append(rec[1] or '')
|
||||
|
||||
return self.defaults
|
||||
|
||||
|
|
|
|||
|
|
@ -299,7 +299,7 @@ def runquery(q='', ret=0, from_export=0):
|
|||
if qm.split()[0].lower() != 'select':
|
||||
raise Exception, 'Query (Max) must be a SELECT'
|
||||
if not webnotes.form_dict.get('simple_query'):
|
||||
qm = add_match_conditions(qm, tl, webnotes.user.get_roles(), webnotes.user.defaults)
|
||||
qm = add_match_conditions(qm, tl, webnotes.user.get_roles(), webnotes.user.get_defaults())
|
||||
|
||||
out['n_values'] = webnotes.utils.cint(sql(qm)[0][0])
|
||||
|
||||
|
|
|
|||
|
|
@ -198,7 +198,7 @@ def build_match_conditions(data, conditions):
|
|||
else:
|
||||
default_key = document_key = d.match
|
||||
|
||||
for v in webnotes.user.defaults.get(default_key, ['**No Match**']):
|
||||
for v in webnotes.user.get_defaults().get(default_key, ['**No Match**']):
|
||||
match_conditions.append('`tab%s`.%s="%s"' % (data['doctype'],
|
||||
document_key, v))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue