How To Navigate to Child Table Doctype List View or Form View -- Is it possible?

Is it possible to navigate directly to child table doctypes in the standard List View or Form View. For example “Payment Schedule” doctype. I would like to be able to see all Payment Schedule records in the doctype List View and navigate to individual records in the Form View.

child tables depend on parent to exist.

not possible out of the box.

custom/workaround if you just need to view.

  1. add whitelisted function / server script that returns frappe.db.sql(), or add custom script report that populates data. This requires programming
  2. install metabase or any bi tool that can list/show table entries from Mariadb. This requires setup of additional app for BI, e.g. metabase

This seems a bit ironic since you can go to Customize Form, enter “Payment Schedule” and see an entire form definition with sections! Why prevent people from interacting directly with child tables? In normal database modeling, there’s no regular-use reason to globally prevent editing of dependent records – in fact, global prevention would be anti-future-proof.

In addition to script reports, you can view all child data as an aggregate list using the standard report builder. It’s fairly point and click.

As Revant suggested, List View and Form View for child docs are not on the horizon anytime soon, since both of those views are tightly coupled with CRUD events that are all defined at the parent-doc level.

What code would I have to edit if I wanted to allow navigating-to and editing-of a child table record in the Form view?

Bottom line up top: Don’t do this

With that out of the way…

From a technical standpoint, it’s just a routing question. In a given user session, routes are built for all documents that the user has read permissions for:

Below the for loop, you could add something like:

this.routes['payment-schedule'] = {doctype: "Payment Schedule"}

…or better yet do it programmatically.

On the backend, child tables inherent all rights from their parent doctype, so there’s no need for additional permissions there. On the frontend, however, child tables don’t have any permissions explicitly set, so you’ll need to also make sure that the has_perm() function in perm.js returns true for your doctype.

I haven’t tested this much, but that seems to be all you need to do to get child doctypes showing up in List and Form Views:

A word of caution: Doing this is pretty much guaranteed to destroy the integrity of your data. You’re bypassing all lifecycle event hooks, which is not a good idea. Frappe wasn’t designed to work this way. I would never do this on a production system. I am sharing only because it’s an interesting glimpse into the inner workings of the frappe desk.

1 Like

@peterg

Very thorough! Thank you!!!