[fix] Share query is always ORed after the AND combination of User Permissions and DocType permission conditions
This commit is contained in:
parent
715dcbc858
commit
d4e9e87af6
1 changed files with 8 additions and 5 deletions
|
|
@ -270,7 +270,6 @@ class DatabaseQuery(object):
|
|||
"""add match conditions if applicable"""
|
||||
self.match_filters = []
|
||||
self.match_conditions = []
|
||||
|
||||
only_if_shared = False
|
||||
|
||||
if not self.tables: self.extract_tables()
|
||||
|
|
@ -295,10 +294,6 @@ class DatabaseQuery(object):
|
|||
self.add_user_permissions(user_permissions,
|
||||
user_permission_doctypes=role_permissions.get("user_permission_doctypes").get("read"))
|
||||
|
||||
# share is an OR condition, if there is a role permission
|
||||
if not only_if_shared and self.shared:
|
||||
self.match_conditions.append(self.get_share_condition())
|
||||
|
||||
if as_condition:
|
||||
conditions = ""
|
||||
if self.match_conditions:
|
||||
|
|
@ -309,6 +304,14 @@ class DatabaseQuery(object):
|
|||
if doctype_conditions:
|
||||
conditions += (' and ' + doctype_conditions) if conditions else doctype_conditions
|
||||
|
||||
# share is an OR condition, if there is a role permission
|
||||
if not only_if_shared and self.shared:
|
||||
if conditions:
|
||||
conditions = "({conditions}) or ({shared_condition})".format(
|
||||
conditions=conditions, shared_condition=self.get_share_condition())
|
||||
else:
|
||||
conditions = "{shared_condition}".format(shared_condition=self.get_share_condition())
|
||||
|
||||
return conditions
|
||||
|
||||
else:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue