fix: false positive attr check while applying permlevel (#20069)

* fix: false positive attr check while applying permlevel

* Revert "fix: false positive attr check while applying permlevel"

This reverts commit 9114788590ce12be977df847c13b00e3bf72ac2a.

* fix: ignore AttributeError while trying to pop low permlevel fields

---------

Co-authored-by: Ankush Menat <ankush@frappe.io>
This commit is contained in:
Rucha Mahabal 2023-02-20 12:18:37 +05:30 committed by GitHub
parent 537172ac02
commit 89d63ea82b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -676,7 +676,11 @@ class Document(BaseDocument):
for df in self.meta.fields:
if df.permlevel and hasattr(self, df.fieldname) and df.permlevel not in has_access_to:
delattr(self, df.fieldname)
try:
delattr(self, df.fieldname)
except AttributeError:
# hasattr might return True for class attribute which can't be delattr-ed.
continue
for table_field in self.meta.get_table_fields():
for df in frappe.get_meta(table_field.options).fields or []: