fix(role): Set desk properties (e.g. search_bar) to 1 for roles with desk access (#21162)

Replace get_doc with new_doc, because default values are not retrieved when using get_doc. Some roles with desk_access had no access to most features of the desk, such as the search bar or the form's sidebar.
This commit is contained in:
Corentin Flr 2023-05-30 07:07:26 +02:00 committed by GitHub
parent 50a8c4423e
commit 66eb377492
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1679,7 +1679,9 @@ def make_module_and_roles(doc, perm_fieldname="permissions"):
for role in list(set(roles)):
if frappe.db.table_exists("Role", cached=False) and not frappe.db.exists("Role", role):
r = frappe.get_doc(dict(doctype="Role", role_name=role, desk_access=1))
r = frappe.new_doc("Role")
r.role_name = role
r.desk_access = 1
r.flags.ignore_mandatory = r.flags.ignore_permissions = True
r.insert()
except frappe.DoesNotExistError as e: