Merge pull request #32192 from henriquefalconer/fix/field-level-permissions-filtering
fix: Field Level Permissions Not Applied Correctly in frappe.get_list
This commit is contained in:
commit
6461592b5d
1 changed files with 6 additions and 9 deletions
|
|
@ -613,7 +613,6 @@ from {tables}
|
|||
if self.flags.ignore_permissions:
|
||||
return
|
||||
|
||||
asterisk_fields = []
|
||||
permitted_fields = set(
|
||||
get_permitted_fields(
|
||||
doctype=self.doctype,
|
||||
|
|
@ -624,7 +623,10 @@ from {tables}
|
|||
)
|
||||
permitted_child_table_fields = {}
|
||||
|
||||
for i, field in enumerate(self.fields):
|
||||
# Create a copy of the fields list and reverse it to avoid index issues when removing fields
|
||||
fields_to_check = list(enumerate(self.fields))[::-1]
|
||||
|
||||
for i, field in fields_to_check:
|
||||
# field: 'count(distinct `tabPhoto`.name) as total_count'
|
||||
# column: 'tabPhoto.name'
|
||||
# field: 'count(`tabPhoto`.name) as total_count'
|
||||
|
|
@ -634,9 +636,10 @@ from {tables}
|
|||
continue
|
||||
|
||||
column = columns[0]
|
||||
# handle * fields
|
||||
if column == "*" and "*" in field:
|
||||
if not in_function("*", field):
|
||||
asterisk_fields.append(i)
|
||||
self.fields[i : i + 1] = permitted_fields
|
||||
continue
|
||||
|
||||
# handle pseudo columns
|
||||
|
|
@ -691,12 +694,6 @@ from {tables}
|
|||
else:
|
||||
self.remove_field(i)
|
||||
|
||||
# handle * fields
|
||||
j = 0
|
||||
for i in asterisk_fields:
|
||||
self.fields[i + j : i + j + 1] = permitted_fields
|
||||
j = j + len(permitted_fields) - 1
|
||||
|
||||
def prepare_filter_condition(self, ft: FilterTuple) -> str:
|
||||
"""Return a filter condition in the format:
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue