Restricted button in version 12

Hi all,

Login as User vice shown Restricted button, please tell me anyone “Restricted” button functionality.

Maybe include a screenshot, to best set the context you refer to here?

Hi

From a quick look at the code: that Restricted button apparently relates to the restrict_to_domain field and the Domainification feature introduced in v8 or so that sets ‘active domain’ control to a specified module, doctype, user role and perhaps field level?

Here’s a test that may help illustrate:

I can’t say where or how this is documented, here’s a code search that may help you explore this:

frappe@ubuntu:~/frappe-bench$ find . -name '*.py' | xargs grep restrict_to_domain
./apps/erpnext/erpnext/patches/v10_0/add_non_profit_domain.py:			'restrict_to_domain': domain
./apps/erpnext/erpnext/patches/v10_0/add_guardian_role_for_parent_portal.py:	'restrict_to_domain': 'Education'
./apps/erpnext/erpnext/patches/v9_0/revert_manufacturing_user_role.py:	frappe.db.set_value('Role', role, 'restrict_to_domain', '')
./apps/frappe/frappe/desk/doctype/desktop_icon/desktop_icon.py:			"ifnull(restrict_to_domain, '')": ("not in", ",".join(active_domains))
./apps/frappe/frappe/desk/moduleview.py:	return filter_by_restrict_to_domain(data)
./apps/frappe/frappe/desk/moduleview.py:def filter_by_restrict_to_domain(data):
./apps/frappe/frappe/desk/moduleview.py:			doctype_domain = frappe.db.get_value(doctype, item.get("name"), "restrict_to_domain") or ''
./apps/frappe/frappe/desk/moduleview.py:		"ifnull(restrict_to_domain, '')": "",
./apps/frappe/frappe/desk/moduleview.py:		"restrict_to_domain": ("in", active_domains)
./apps/frappe/frappe/core/doctype/doctype/doctype.py:		if hasattr(doc,'restrict_to_domain') and doc.restrict_to_domain and \
./apps/frappe/frappe/core/doctype/doctype/doctype.py:			not frappe.db.exists('Domain', doc.restrict_to_domain):
./apps/frappe/frappe/core/doctype/doctype/doctype.py:			frappe.get_doc(dict(doctype='Domain', domain=doc.restrict_to_domain)).insert()
./apps/frappe/frappe/core/doctype/domain_settings/domain_settings.py:		'''Disable all restricted roles and set `restrict_to_domain` property in Module Def'''
./apps/frappe/frappe/core/doctype/domain_settings/domain_settings.py:		frappe.db.set_value('Module Def', module, 'restrict_to_domain', domain)
./apps/frappe/frappe/core/doctype/domain_settings/domain_settings.py:		frappe.db.set_value('Role', role, 'restrict_to_domain', domain)
./apps/frappe/frappe/core/doctype/domain_settings/domain_settings.py:		for m in frappe.get_all("Module Def", fields=['name', 'restrict_to_domain']):
./apps/frappe/frappe/core/doctype/domain_settings/domain_settings.py:		if (not m.restrict_to_domain) or (m.restrict_to_domain in active_domains):
./apps/frappe/frappe/core/doctype/user/user.py:		"ifnull(restrict_to_domain, '')": "",
./apps/frappe/frappe/core/doctype/user/user.py:		"restrict_to_domain": ("in", active_domains)
./apps/frappe/frappe/core/page/permission_manager/permission_manager.py:	"ifnull(restrict_to_domain, '')": "",
./apps/frappe/frappe/core/page/permission_manager/permission_manager.py:	"restrict_to_domain": ("in", active_domains)
./apps/frappe/frappe/core/page/permission_manager/permission_manager.py:	"ifnull(restrict_to_domain, '')": "",
./apps/frappe/frappe/core/page/permission_manager/permission_manager.py:	"restrict_to_domain": ("in", active_domains)
./apps/frappe/frappe/utils/user.py:			read_only, restrict_to_domain, module from tabDocType""", as_dict=1):
./apps/frappe/frappe/utils/user.py:			if (not r.restrict_to_domain) or (r.restrict_to_domain in active_domains):
./apps/frappe/frappe/tests/test_domainification.py:		test_doctype.restrict_to_domain = "_Test Domain 2"
./apps/frappe/frappe/tests/test_domainification.py:		test_role.restrict_to_domain = "_Test Domain 2"
./apps/frappe/frappe/tests/test_domainification.py:		test_doctype.restrict_to_domain = "_Test Domain 2"
./apps/frappe/frappe/tests/test_domainification.py:		test_module_def.restrict_to_domain = "_Test Domain 2"
./apps/frappe/frappe/tests/test_domainification.py:		test_module_def.restrict_to_domain = ""

It indicates that there is a user permission applied for that user based on some condition. Clicking on Restricted will show you the said conditions.

2 Likes
Yeah , i saw clicked on restricted button and it's shown field value . but how it's take  link  field value (ex. Employee it's automatically take employee id and it's starts restricted)? 

I would like to know what happen here…

For employees, when you’re linking the employee master and the user ID, there is an option to Create User Permission.

To cross check, you can go to the User Permission list and see.

Thanks for reply …
got it now…thanks u so much @kennethsequeira