I am trying to add Block_Modules list for Employees when the user is created via hooks.py.
I have created a custom app mycustomization, in that apps hook.py I have the following statement.
doc_events = {
"User": {
"validate": "mycustomization.mycustomization.user_addblockmodules"
}
}
and then in the mycustomization folder I have a file named user_addblockmodules.py
the code for the file is as follows
from __future__ import unicode_literals
import frappe
from frappe.model.document import Document
@frappe.whitelist()
def user_addblockmodules(doc, method=None):
if len(doc.get("roles")) == 1:
if "Employee" in [d.role for d in doc.get("roles")]:
doc.append("block_modules", {
'module': "Users and Permissions",
'module': "Integrations",
'module': "Social",
'module': "dashboard",
'module': "Accounts",
'module': "Buying",
'module': "Assets",
'module': "CRM",
'module': "Help",
'module': "Bench Manager",
'module': "Settings",
'module': "Customization",
'module': "Website",
'module': "Leaderboard",
'module': "Getting Started",
'module': "Selling",
'module': "Stock",
'module': "Quality Management",
'module': "Marketplace"})
But I keep getting error when a new user is created. I have restarted bench, reloaded the site.
AttributeError: module ‘mycustomization.mycustomization’ has no attribute ‘user_addblockmodules’
Any idea where I am going wrong? Thanks.