I want to remove an item from child table. I have searched but I can not find any sample code.
To delete a line item from a childtable in Python you will have to use frappe.delete_doc(“Doctype”,“Docname”). In this case, it will be the child Doctype and its name(line-item that you wish to delete) and a refresh_field(‘childtables_name’) would do wonders in case if it is done using a frappe.call from js
Use
doc.remove(row)
Example usage:
5 Likes
What is the expected input for row
? A document or an index?
It should be the child doc
Your response works fine removing the child, however that method doesn’t rearrange (update idx) on the table causing this (see picture)
which method can i call to fix the idxs as well.
Thanks
You’ll need to set the idx
column explicitly.
for row, index in enumerate(doc.items):
row.idx = index
2 Likes