Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DocType names should be namespace to the module they belong to #13337

Open
mingfang opened this issue May 25, 2021 · 4 comments
Open

DocType names should be namespace to the module they belong to #13337

mingfang opened this issue May 25, 2021 · 4 comments

Comments

@mingfang
Copy link

Currently DocType names must be globally unique.
As a result it is very easy for DocType names to conflict with each other when adding third party modules.
Worst yet, the conflicts are happens without warning; newer DocTypes with the same name simply "hide" the other older one.

To avoid this problem, I manually prefix the names of my DocTypes to try to keep it unique.
The problem with my approach is

  • there's no guaranteed that my prefix won't conflict with a third party
  • the prefix makes my DocType names long and ugly
  • Sometimes I forget to add the prefix, because it's not natural to do

A better way would be for Frappe to automatically "namespace" DocTypes to the module they belong to.
e.g. The Account DocType in the Accounts module shall automatically be named Accounts.Account.

To make the code compatible we can default to the current namespace when one is not supplied in the code.
e.g.

account = frappe.get_doc('Account', 'ACCOUT00002')

shall mean

account = frappe.get_doc('Accounts.Account', 'ACCOUT00002')
@krishnakanthati
Copy link
Contributor

What do you mean by 'third party modules'?

@mingfang
Copy link
Author

By third party I meant anything module not written by myself.
I can control the DocType names for the code that I write but I can't control other people's code.
Take the simple example of the Article DocType from the official tutorial https://frappeframework.com/docs/user/en/tutorial
and the Education module from ERPNext https://docs.erpnext.com/docs/user/manual/en/education/lms-masters
There's no reason why the two different Articles can't/shouldn't co-exist, but currently it's not possible.
My proposal is to "namespace" the two Articles so that we can reference them as library_management.Article and education.Article for example.

@krishnakanthati
Copy link
Contributor

Got it. Thanks @mingfang

@mingfang
Copy link
Author

any update on this.
Currently I'm manually prefixing all my doctype names as a workaround.
It's really ugly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants