Polymorphic links
Runtime-typed foreign keys — the 67 edges no static ERD can draw.
A Dynamic Link stores the target’s name while a companion field holds the target’s doctype.
The pair behaves as a foreign key whose table is chosen at runtime, so these edges cannot be drawn
in a static ERD — but they are load-bearing, especially for party handling and document
back-references. 67 such fields exist in scope.
| Entity | Module | Link field | Doctype held in |
|---|---|---|---|
| Accounting Dimension Detail | Accounts | default_dimension |
reference_document |
| Advance Payment Ledger Entry | Accounts | against_voucher_no |
against_voucher_type |
| Advance Payment Ledger Entry | Accounts | voucher_no |
voucher_type |
| Allowed Dimension | Accounts | dimension_value |
accounting_dimension |
| Appointment | CRM | party |
appointment_with |
| Asset Movement | Assets | reference_name |
reference_doctype |
| Authorization Rule | Setup | master_name |
customer_or_item |
| Bank Account | Accounts | party |
party_type |
| Bank Guarantee | Accounts | reference_docname |
reference_doctype |
| Bank Transaction | Accounts | party |
party_type |
| Bank Transaction Payments | Accounts | payment_entry |
payment_document |
| Bank Transaction Rule | Accounts | party |
party_type |
| Bank Transaction Rule Accounts | Accounts | party |
party_type |
| Batch | Stock | reference_name |
reference_doctype |
| Contract | CRM | document_name |
document_type |
| Contract | CRM | party_name |
party_type |
| Email Campaign | CRM | recipient |
email_campaign_for |
| Exchange Rate Revaluation Account | Accounts | party |
party_type |
| GL Entry | Accounts | against_voucher |
against_voucher_type |
| GL Entry | Accounts | party |
party_type |
| GL Entry | Accounts | voucher_no |
voucher_type |
| Journal Entry Account | Accounts | advance_voucher_no |
advance_voucher_type |
| Journal Entry Account | Accounts | party |
party_type |
| Journal Entry Account | Accounts | reference_name |
reference_type |
| Journal Entry Template Account | Accounts | party |
party_type |
| Landed Cost Item | Stock | receipt_document |
receipt_document_type |
| Landed Cost Purchase Receipt | Stock | receipt_document |
receipt_document_type |
| Loyalty Point Entry | Accounts | invoice |
invoice_type |
| Maintenance Visit Purpose | Maintenance | prevdoc_docname |
prevdoc_doctype |
| Opportunity | CRM | party_name |
opportunity_from |
| Party Link | Accounts | primary_party |
primary_role |
| Party Link | Accounts | secondary_party |
secondary_role |
| Party Specific Item | Selling | based_on_value |
restrict_based_on |
| Party Specific Item | Selling | party |
party_type |
| Payment Entry | Accounts | party |
party_type |
| Payment Entry Reference | Accounts | advance_voucher_no |
advance_voucher_type |
| Payment Entry Reference | Accounts | reference_name |
reference_doctype |
| Payment Ledger Entry | Accounts | against_voucher_no |
against_voucher_type |
| Payment Ledger Entry | Accounts | party |
party_type |
| Payment Ledger Entry | Accounts | voucher_no |
voucher_type |
| Payment Order Reference | Accounts | reference_name |
reference_doctype |
| Payment Request | Accounts | party |
party_type |
| Payment Request | Accounts | reference_name |
reference_doctype |
| Process Payment Reconciliation | Accounts | party |
party_type |
| Process Statement Of Accounts | Accounts | collection_name |
customer_collection |
| Purchase Invoice Advance | Accounts | reference_name |
reference_type |
| Quality Feedback | Quality Management | document_name |
document_type |
| Quality Inspection | Stock | reference_name |
reference_type |
| Quality Meeting Minutes | Quality Management | document_name |
document_type |
| Quotation | Selling | party_name |
quotation_to |
| Quotation Item | Selling | prevdoc_docname |
prevdoc_doctype |
| Repost Accounting Ledger Items | Accounts | voucher_no |
voucher_type |
| Repost Item Valuation | Stock | voucher_no |
voucher_type |
| Repost Payment Ledger Items | Accounts | voucher_no |
voucher_type |
| Sales Invoice Advance | Accounts | reference_name |
reference_type |
| Serial No | Stock | reference_name |
reference_doctype |
| Serial and Batch Bundle | Stock | voucher_no |
voucher_type |
| Service Level Agreement | Support | entity |
entity_type |
| Stock Ledger Entry | Stock | voucher_no |
voucher_type |
| Stock Reservation Entry | Stock | from_voucher_no |
from_voucher_type |
| Stock Reservation Entry | Stock | voucher_no |
voucher_type |
| Subscription | Accounts | party |
party_type |
| Tax Withholding Entry | Accounts | party |
party_type |
| Tax Withholding Entry | Accounts | taxable_name |
taxable_doctype |
| Tax Withholding Entry | Accounts | withholding_name |
withholding_doctype |
| Unreconcile Payment | Accounts | voucher_no |
voucher_type |
| Unreconcile Payment Entries | Accounts | reference_name |
reference_doctype |
The recurring patterns:
| Pattern | Fields | Used for |
|---|---|---|
| Party | party_type + party |
Payment Entry, GL Entry, Payment Ledger Entry — a party is a Customer, Supplier, Employee or Shareholder. |
| Reference | reference_doctype + reference_name |
Linking a payment, journal row or ledger entry back to the document that caused it. |
| Against voucher | voucher_type + voucher_no |
Stock Ledger Entry and GL Entry pointing at their originating transaction. |
| Link | link_doctype + link_name |
Address and Contact attachment to any party. |
| Allocation | allocated_to_doctype + allocated_to |
Serial/batch and reservation allocation. |