fix: Permit no fields if dt is table and no parenttype is specified
This commit is contained in:
parent
5829dabf74
commit
db209cbdf7
2 changed files with 5 additions and 1 deletions
|
|
@ -539,6 +539,9 @@ class Meta(Document):
|
|||
"""
|
||||
permitted_fieldnames = []
|
||||
|
||||
if self.istable and not parenttype:
|
||||
return permitted_fieldnames
|
||||
|
||||
if not self.get_permissions(parenttype=parenttype):
|
||||
return self.get_fieldnames_with_value()
|
||||
|
||||
|
|
|
|||
|
|
@ -48,13 +48,14 @@ class TestModelUtils(FrappeTestCase):
|
|||
picked_doctype_all_columns = frappe.get_meta(picked_doctype).get_valid_columns()
|
||||
self.assertSequenceEqual(core_permitted_fields, picked_doctype_all_columns)
|
||||
|
||||
# access to child tables' fields is restricted to default fields unless parent is passed & permitted
|
||||
# access to child tables' fields is restricted to no fields unless parent is passed & permitted
|
||||
with set_user("Administrator"):
|
||||
without_parent_fields = get_permitted_fields("Installed Application")
|
||||
with_parent_fields = get_permitted_fields(
|
||||
"Installed Application", parenttype="Installed Applications"
|
||||
)
|
||||
child_all_fields = frappe.get_meta("Installed Application").get_valid_columns()
|
||||
self.assertEqual(without_parent_fields, [])
|
||||
self.assertLess(len(without_parent_fields), len(with_parent_fields))
|
||||
self.assertSequenceEqual(set(with_parent_fields), set(child_all_fields))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue