Custom app calling doctypes from different modules

Hello everyone,
I am making a new app that is gathering a series of existing doctypes from ERPnext into the same place. I noticed that there is a way in the backend, of course, to call for other doctypes from other modules. If you take a look at the Accounts Module of ERPnext. You will notice a section call Masters and it contains doctypes from the Selling Module. That’s what I am trying to achieve here, I looked at the desktop.py for Accounts and saw the code that I thought would link this, so I made a quick example in my custom app but nothing pulls through. There we no tutorials on how to do this, can anyone help me grasp this concept.

Here the code I used.

-- coding: utf-8 --

from future import unicode_literals
from frappe import _

def get_data():
return [
{
“module_name”: “Membership”,
“color”: “#1777CB”,
“icon”: “fa fa-users”,
“type”: “module”,
“label”: _(“Membership”)
},
{
“label”: _(“Masters”),
“items”: [
{
“type”: “doctype”,
“name”: “Customer”,
“description”: _(“Customer database.”)
},
{
“type”: “doctype”,
“name”: “Supplier”,
“description”: _(“Supplier database.”)
},
{
“type”: “doctype”,
“name”: “Item”,
},
{
“type”: “doctype”,
“name”: “Asset”,
},
{
“type”: “doctype”,
“name”: “Asset Category”,
}
]
},
]

What exactly are you trying to do with this?

If you want to pull in a document, just use frappe.get_doc, or frappe.get_value for single values.

If you want a whole set of data, using frappe.db.sql queries can be quicker / easier.

I think @Angel_Marchena is attempting to add doctype links to his custom module. As in, there’s a link to Item in Accounts, but Item lives in Stock.

1 Like

That is correct, I want to call different doctypes from other modules. I am trying to create a module that gathers specify doctypes in one place.

Would this work to call something similar to this.

as you see here this is the Accounts Module, but it has the “Master” Section with multiple Doctypes that are of a different module.

have a look at:

https://github.com/frappe/erpnext/blob/develop/erpnext/config/accounts.py#L80

That is where I pulled my code from, never the less it working at all. Remember this is in a custom app. Even when I try to install it gives me an error. I think on the top of the code its needs to import from ERPnext.

Honestly I am not getting your point on what you need to do …

As I stated before in the original post, I am making a custom app that is gathering certain doctypes from other modules. I pulled the code from your sample before…its the same code I used in one of my examples…It doesn’t work its missing something.

Can you share a link to your repo so we can see your full code?

Did u install erpnext app?

I posted the full code of the desktop.py inside the custom app

# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from frappe import _

def get_data():
        return [
                {
                        "module_name": "Membership",
                        "color": "#1777CB",
                        "icon": "fa fa-users",
                        "type": "module",
                        "label": _("Membership")
                },
                        "label": _("Masters"),
                        "items": [
  {
                                {
                                        "type": "doctype",
                                        "name": "Customer",
											"description": _("Customer database.")
                                },
                                {
                                        "type": "doctype",
                                        "name": "Supplier",
                                        "description": _("Supplier database.")
                                },
                                {
                                        "type": "doctype",
                                        "name": "Item",
                                },
                                {
                                        "type": "doctype",
                                        "name": "Asset",
                                },
                                {
                                        "type": "doctype",
                                        "name": "Asset Category",
                                }
                        ]
                },
        ]

Ofcourse.

@Angel_Marchena Go to config folder, delete desktop.pyc and reload page.

And you have to put the code inside config/yourmodulename.py

There is no file like that in the custom APP.

That means desktop.py is not getting compiled in your app …

I did this, it still not working, I checked the code and corrected a couple of syntax errors, but nothing its pulling through, the APP won’t even show on Erpnext

did u install the app?

Yeah. Man here is the code
# -- coding: utf-8 --
from future import unicode_literals
from frappe import _
from erpnext import _

def get_data():
        return [
                {
                        "module_name": "Membership",
                        "color": "#1777CB",
                        "icon": "fa fa-users",
                        "type": "module",
                        "label": _("Membership")
                },
  {
                        "label": _("Masters"),
                        "items": [
                                                       {
                                {
                                        "type": "doctype",
                                        "name": "Customer",
                                                                                                                                                       "description": _("Customer database.")
                                },
                                {
                                        "type": "doctype",
                                        "name": "Supplier",
                                        "description": _("Supplier database.")
                                },
                                {
                                        "type": "doctype",
                                        "name": "Item",
                                },
                                {
                                        "type": "doctype",
                                        "name": "Asset",
                                },
                                {
                                        "type": "doctype",
                                        "name": "Asset Category",
                                },
                                }
                        ]
                }
        ]

Let me know if you know how to because I feel stupid.