Created
April 2, 2025 04:58
-
-
Save ManotLuijiu/7e7241bd5502508b2e603cd779a8850d to your computer and use it in GitHub Desktop.
How to get Relations between Tables in ERPNext
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bench --site your_site_name console |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get all doctypes | |
doctypes = frappe.db.sql("SELECT name FROM `tabDocType` WHERE istable=0 AND issingle=0", as_dict=1) | |
# For each doctype, get link fields | |
for d in doctypes: | |
dt = frappe.get_meta(d.name) | |
links = dt.get_link_fields() | |
if links: | |
print(f"DocType: {d.name}") | |
for link in links: | |
print(f" → Links to {link.options} via field {link.fieldname}") | |
print("") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to exit console:
type: exit()
then press "Enter" button