refactor: skip permlevel check if all levels are 0 (#24727)

* refactor: skip permlevel check if all levels are 0

* chore: fix outdated docstring

* chore: equality instead of le
This commit is contained in:
Raffael Meyer 2024-02-05 06:19:09 +01:00 committed by GitHub
parent 78f20040a5
commit 6c8a08d955
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -679,23 +679,15 @@ class Document(BaseDocument):
return same
def apply_fieldlevel_read_permissions(self):
"""Remove values the user is not allowed to read (called when loading in desk)"""
"""Remove values the user is not allowed to read."""
if frappe.session.user == "Administrator":
return
has_higher_permlevel = False
all_fields = self.meta.fields.copy()
for table_field in self.meta.get_table_fields():
all_fields += frappe.get_meta(table_field.options).fields or []
for df in all_fields:
if df.permlevel > 0:
has_higher_permlevel = True
break
if not has_higher_permlevel:
if all(df.permlevel == 0 for df in all_fields):
return
has_access_to = self.get_permlevel_access("read")