From db209cbdf7d367f91fc89524a1539cc2bc990930 Mon Sep 17 00:00:00 2001 From: Gavin D'souza Date: Mon, 6 Feb 2023 13:33:49 +0530 Subject: [PATCH] fix: Permit no fields if dt is table and no parenttype is specified --- frappe/model/meta.py | 3 +++ frappe/tests/test_model_utils.py | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/frappe/model/meta.py b/frappe/model/meta.py index b6c2895c96..acc3b28477 100644 --- a/frappe/model/meta.py +++ b/frappe/model/meta.py @@ -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() diff --git a/frappe/tests/test_model_utils.py b/frappe/tests/test_model_utils.py index ee2dfec628..25523012e9 100644 --- a/frappe/tests/test_model_utils.py +++ b/frappe/tests/test_model_utils.py @@ -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))