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

feat: virtual child doctypes #19254

Closed
wants to merge 1 commit into from

Conversation

alias
Copy link
Contributor

@alias alias commented Dec 12, 2022

allow virtual child tables by looking up child doctypes controller class an call its get_list

It is actually a small change that FMO dramatically increases the usefulness of virtual doctypes, which can now be child tables too.
I came across two small design issues (not really related to this)

  • The handover of the parent into the get_list method (or any other child table controller method) is useful, as the (static) child controller has otherwise no way to figure out its parent (without risking a loop).
  • the (boiler plate) virtual child table controller has all methods of a regular controller, - all of them are not used for a child table, so perhaps the boilerplate can be shrinked in case of child doc types to just that get_list(parent).

allow virtual child tables by looking up child doctypes controller class
@alias alias requested a review from a team as a code owner December 12, 2022 20:31
@alias alias requested review from phot0n and removed request for a team December 12, 2022 20:31
@github-actions github-actions bot added the add-test-cases Add test case to validate fix or enhancement label Dec 12, 2022
@git-avc
Copy link
Contributor

git-avc commented Dec 12, 2022

💜

controller = get_controller(df.options)
data = controller.get_list({'parent_doc': self})
self.set(df.fieldname, data)
continue
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This alone wont support virtual child tables.

Firstly, there are following use cases:

  1. Attaching a virtual child table virtual doctype.
  2. Attaching a virtual child table to normal doctype.
  3. Attaching same child table to multiple doctypes.

For all three cases, we should be able to do at least basic CRUD:

  1. Create new rows on existing or new parent documents.
  2. Read rows when parent is read. (only this seems to be achieved)
  3. Update individual row.
  4. Delete individual rows.

If you can achieve this in PR then we can proceed. Else merging just partial implementation is no good. Just reading can be achieved by copying these 3-4 lines of code to relevant doctype controller too.

@ankush ankush marked this pull request as draft December 13, 2022 05:30
@ankush ankush changed the title allow virtual child tables feat: virutal child doctypes Dec 13, 2022
@alias alias changed the title feat: virutal child doctypes feat: virtutal child doctypes Dec 18, 2022
@alias alias changed the title feat: virtutal child doctypes feat: virtual child doctypes Dec 18, 2022
@alias
Copy link
Contributor Author

alias commented Dec 18, 2022

" Just reading can be achieved by copying these 3-4 lines of code to relevant doctype controller too."

Thats true, Thank you

@alias alias closed this Dec 18, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
add-test-cases Add test case to validate fix or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants