Multi-tenant and private contacts

Hello experts,

I want to use 1 instance of ERPNext for multiple teams within a company. I want to treat each team as a tenant.

Is it possible to have multi-tenant, and the contacts stay within each tenant?

In addition, within each tenant, each member to have their own private contacts? Suppliers and Customers not to be used atm.

if you build custom apps with frappe framework it is possible to add a doctype for “Team” and add a link field of team on each doctype to be restricted to tenant.

add a user permission that restricts the user by “Team” instance. This can be added using custom whitelisted onboard function.

you can’t use naming series in such apps, as the series doesn’t reset for each tenant. in case of naming series, add a human readable naming series field that generates tenant based naming series increment. actual name field has nothing to do with such custom naming series

in case of ERPNext this is not possible as tenancy separation is based only on site.

1 Like

@revant_one I’m thinking if I can emulate Leave Application’s design and apply it on to Contacts. I believe Leave Application is created by a staff, only can be seen by/approved by his supervisor, and the staff and manager can have certain kind of workflow.

They are very similar, right? Do you think I can use this approach to set it up?

The closest we can reach for “tenant key” based single database multi-tenant app with frappe framework is with a “tenant” doctype link field on each document created by app and user permission set to “tenant” doctype.

I feel Workflow fits well where there is low-code, no-code scenario for end users to set it up quickly from web ui. May be add some minimal tweaks from scripts.

If you try to force thing on to Workflow you’ll have to handle many cases and add that to upgrade and maintenance overhead. Workflow actions are being created for every user

1 Like

In the case you mention, I believe the solution is not to use multi tenant; 1 instance of ERPNext per company. Please correct me if I’m wrong.

Things are starting to look good… fingers crossed. I’m studying the Employee and Leave Application DocType, and really really hope to clone the approach to Contacts.

Yes. I’m not even talking about ERPNext. I’m just talking about Frappe Framework.

ERPNext is 1 db 1 tenant as design.

1 Like

Thank you thank you. Much appreciated.

May I ask again, not considering the multi-tenant now, Contacts DocType has a field “User Id” which links the contact to a user. This relationship can be and is set each time a Contact is created.

The only “fix” to implement is to set up a rule / filter to not display those Contacts not belonging to User.

Am I correct in this regard? I believe it is safer to implement this logic in Server Script instead of Client Script. Am I right?

PS: I mistaken the field “User Id”; it is used to link this Contact to ERPNext user. Therefore I still need to create a Custom Field to hold the Creator, and filter it and match it to Logged in user.