Merge pull request #4104 from nabinhait/addresses_and_contacts
[fix] get permission query condition if no permitted links
This commit is contained in:
commit
8e7e128e81
@ -53,13 +53,23 @@ def get_permission_query_conditions(doctype):
|
|||||||
if not links.get("not_permitted_links"):
|
if not links.get("not_permitted_links"):
|
||||||
# when everything is permitted, don't add additional condition
|
# when everything is permitted, don't add additional condition
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
elif not links.get("permitted_links"):
|
||||||
|
conditions = []
|
||||||
|
|
||||||
|
# when everything is not permitted
|
||||||
|
for df in links.get("not_permitted_links"):
|
||||||
|
# like ifnull(customer, '')='' and ifnull(supplier, '')=''
|
||||||
|
conditions.append("ifnull(`tab{doctype}`.`{fieldname}`, '')=''".format(doctype=doctype, fieldname=df.fieldname))
|
||||||
|
|
||||||
|
return "( " + " and ".join(conditions) + " )"
|
||||||
|
|
||||||
else:
|
else:
|
||||||
conditions = []
|
conditions = []
|
||||||
|
|
||||||
for df in links.get("permitted_links"):
|
for df in links.get("permitted_links"):
|
||||||
# like ifnull(customer, '')!='' or ifnull(supplier, '')!=''
|
# like ifnull(customer, '')!='' or ifnull(supplier, '')!=''
|
||||||
conditions.append("ifnull(`tab{doctype}`.`{fieldname}`, '')!=''".format(doctype=doctype, fieldname=df.fieldname))
|
conditions.append("ifnull(`tab{doctype}`.`{fieldname}`, '')!=''".format(doctype=doctype, fieldname=df.fieldname))
|
||||||
|
|
||||||
return "( " + " or ".join(conditions) + " )"
|
return "( " + " or ".join(conditions) + " )"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user