In custom module, how to restrict user to allowed company only

Have you ever encountered an issue in Frappe where user permissions are assigned, yet certain records still appear to users who shouldn't have access? 🤔 This can be confusing, especially when you believe the permissions should restrict visibility…..

For instance, imagine you’ve assigned company permissions, but other records still show up in user views 🤔🤔. This issue often arises when the field value is empty in those documents.

To address this, Frappe offers a feature in the System Settings called "Apply Strict User Permissions." Enabling this option ensures that records where the field value is empty—such as the company field—will not be visible to users who do not have the appropriate permissions.

How to Enable Strict User Permissions

  1. Navigate to System Settings in your Frappe application.
  2. Look for the "Apply Strict User Permissions" setting.
  3. Enable this option and save your changes.

image.png