fix in permission engine: allow restrictions based on custom field
This commit is contained in:
parent
f9a3c8fcdc
commit
e9c6ecc0d8
@ -81,7 +81,12 @@ class DocType:
|
||||
# get default values
|
||||
# ------------------
|
||||
def get_defaults(self, arg):
|
||||
match_key, with_profiles = arg.split('~~~')
|
||||
if isinstance(arg, basestring):
|
||||
import json
|
||||
arg = json.loads(arg)
|
||||
|
||||
match_key = arg["match"]
|
||||
with_profiles = arg["profiles"]
|
||||
|
||||
pl = ol = []
|
||||
|
||||
@ -89,7 +94,9 @@ class DocType:
|
||||
dl = [a for a in sql("select parent, ifnull(parenttype,'') as parenttype, ifnull(defvalue,'') as defvalue from tabDefaultValue where defkey=%s order by parenttype desc, parent asc", match_key, as_dict=1)]
|
||||
|
||||
# options
|
||||
tn = sql("select options from tabDocField where fieldname=%s and fieldtype='Link' and docstatus=0 limit 1", match_key)[0][0]
|
||||
tn = webnotes.get_doctype(arg["doctype"]).get_options(match_key)
|
||||
|
||||
# tn = sql("select options from tabDocField where fieldname=%s and fieldtype='Link' and docstatus=0 limit 1", match_key)[0][0]
|
||||
ol = [''] + [a[0] for a in sql("select name from `tab%s` where ifnull(docstatus,0)=0" % tn)]
|
||||
|
||||
# roles
|
||||
|
@ -287,7 +287,11 @@ pscript.PermEngine.prototype.show_match_dialog=function(details) {
|
||||
me.render_match_dialog(r, details);
|
||||
}
|
||||
// load the rules
|
||||
$c_obj('Permission Control','get_defaults', details.match + '~~~' + (this.profiles ? 'No' : 'Yes'), callback);
|
||||
$c_obj('Permission Control','get_defaults', {
|
||||
match: details.match,
|
||||
profiles: this.profiles ? "No" : "Yes",
|
||||
doctype: sel_val(me.type_select)
|
||||
}, callback);
|
||||
}
|
||||
|
||||
// --------------------------------------------
|
||||
|
Loading…
x
Reference in New Issue
Block a user