Question Regarding multi-tenant or Multi-Company

Hello,

I’m trying to run a multi-company environment. Each company has his own data. There is no shared data between company but I want to share the customizations.

For example, if I add some doctypes I need these doctypes in all companies. The same for custom fields, translations…

Which is the best way to do it?

3 Likes

Multi-tenant is the best way to go.
THis means that you have different sites that share the same bench directory (created by bench init command).
You have a common apps directory where the apps like frappe, ERPNext, and your own customizations exist.
You sites will share the same code base, but will be stored in different databases (same mariadb)


Multi-Company means you share one site for different companies. This means that the Companies have the possibility of accessing common data (like items, warehouses, even employees., this is good for intra-company setups.


if you have an application where the customizations are totally different, you may also create separate frappe-bench directories, by issuing multiple bench init commands and placing the sites on these different frappe-bench directories (which have different names). THis allows you to share the same mariadb and the same server (or VPS), but have totally different and independent application setups.

2 Likes

There are 2 possible solutions.

  • Create an app and create seperate instances for your companies.
  • Transactions has company field which you can create permissions but Items/Customers/Suppliers doesn’t have a company field. You need to add it and create permissions for that. But then reports and other things will get harder to customize.

I would recommend the first one. You also need to search in the forum. Each week I came across a similar post.

create separate sites in the same frappe-bench folder

1 Like

Yes, seperate sites not instances.

1 Like

There are 3 possible solutions:

  1. Same Server, separate frappe-bench folders (separate apps, separate data, separate companies)
  2. Same Server, Same Frappe-bench folder, different sites (same apps, separate data, separate companies)
  3. Same Server, Same Frappe-bench folder, same site, separate companies. (same appes, shared data, separate companies)

Your best option is option #2

1 Like

Just a small question here: when multitenant is used, it has same app as stated by everyone here. So does it mean that if i make a customization in one site it would also be applied to all the sites / companies hosted using the multitenant option?

Customizations are not shared between companies. I’ve just tested it.

@restos99 thanks for sharing your experience.

This means its basically complete different sites/application installations but sharing only the server resources.

This topic reminds me to propose the name change from Companies to Branches.

Yes or at least I don’t know how to share the app and customizations to other sites in the same server….

Companies are very much different from branches.

In ERPNext Companies function as distinct legal entities

1 Like

when you do bench install-app into the different sites. All those different sites will share the same code base of the apps stored at the apps subdirectory of the frappe-bench directory.

Customization done on the front end of a particular site - ends up only in the database of the particular site - at the moment. However when you use use fixtures and hooks, all the sites in the frappe-bench directory will share those Customizations.

This is an important note. When you do add custom fields, write custom scripts, or add DocType with a checked Custom checkbox in the front end of a particular site (company), these customizations are stored only in the database. So, it will affect only the particular site.

To share these customizations, you use export fixtures and hooks, and the sites in that frappe-bench folder will have those same custom codes, fields, and doctypes.

However, the “customizations” you coded directly to your own app will be shared by the sites.

1 Like

Thank you.

Will search them.

I meant the Company in the Company doctype. Since it shares some common data bases, it’s more like branches than separate company.

The multi tenant, since it has different database and business arrangements, serves more like distinctive independent legal entities, i.e companies

Yes you are right. It’s like branches in business. Sites/instances seems like company.

For your problem, I would create an app locally (bench new-app test), then upload to the server.

bench get-app test ...
bench install-app test --site site1

Then I would develop and test locally. And just pull changes in the server. Something like.

cd test
git pull upstream master

That way you can propogate all your changes to all your sites/instances .

As @TurkerTunali mentioned, not every ERPNext table (DocType) is separated by a “Company”. Some big outliers are:

  • Customers
  • Suppliers
  • Items

For this reason (and a few others, related to roles and permissions), the “Multi Company” feature of ERPNext has its limits. It’s not as robust as something like MS Dynamics, which automatically splits every SQL table, per company.

As others have mentioned, this means that Multi-Tenant (aka multi-site), or Multi -Instance/Server may be the best approaches for separating data by legal entity.

1 Like

bench update also does the job if you installed the app using bench get-app

1 Like

in one site i create a doctype in a crm module in a developer mode, it creates a py,js,json,test.py,init.py,pycache for the doctype…but it didn’t reflect in the other site. i don’t know why.?