我认为@ChillarAnand 回答的解决方案很有帮助。
相反,我想提供一种不同的方法来解决您面临的问题。根据您的问题,目标是从仓库位置(子表)中仅删除一条记录。
# 1. Get the parent document for the warehouse location.
parent_doc = frappe.get_doc("Doctype", docname)
# 2. iterate through the child table rows to find the row meet your filter
# and assign to row_to_detele for late use or you can delete straight away
row_to_delete = ""
for row in parent_doc.warehouse_locations:
if row.modified == last_record_to_keep[0].modified:
row_to_delete = row.name
break
# 3. to remove the child table from the parent doc method
parent_doc.remove(row_to_delete)
的文档parent_doc.remove()
,可以通过以下github路径找到:https ://github.com/frappe/frappe/blob/6b91ade73c07dc1c070ed137cf54a29a3e7b0993/frappe/model/base_document.py#L210 (2021年10月7日)