Delete a child table row of some other document using python, While in some other doctype I want to delete a child row of another doctype, how to achieve this? I tried and fetch that document of child table and delete it but it says submitted document cannot be deleted
In most cases the difference between unSubmitted and Submitted is reflected in the record attribute docstatus
. Often draft
is docstatus = 0
and submitted
is docstatus = 1
. DocTypes with a more complex workflow may define those differently.
Trying to remove a single row (identified by “detailName”) from a child table (“details”) of a DocType (“master”), I found that this works:
def removeSingleRow(master, detailName):
theDetail = None
for detail in master.details:
if detail.name == detailName:
theDetail = detail
print('master.remove(theDetail)')
master.remove(theDetail)
master.save()
frappe.db.commit()
I have not checked on the effect of the docstatus
flag on that operation. There are a number of possibilities to consider:
- docstatus of master
- docstatus of details child table
- docstatus of details row
-
Allow on Submit
setting of any of the above