From 76779e74524452c59921780e411b954a79123f7d Mon Sep 17 00:00:00 2001 From: Sagar Vora Date: Thu, 31 Mar 2022 10:08:32 +0530 Subject: [PATCH] fix: incorrect logic for parenttype parameter in `get_all_children` --- frappe/model/document.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/frappe/model/document.py b/frappe/model/document.py index 3848fa8029..b3c6f6ef20 100644 --- a/frappe/model/document.py +++ b/frappe/model/document.py @@ -848,16 +848,19 @@ class Document(BaseDocument): frappe.CancelledLinkError) def get_all_children(self, parenttype=None): - """Returns all children documents from **Table** type field in a list.""" - ret = [] - for df in self.meta.get("fields", {"fieldtype": ['in', table_fields]}): - if parenttype: - if df.options==parenttype: - return self.get(df.fieldname) + """Returns all children documents from **Table** type fields in a list.""" + + children = [] + + for df in self.meta.get_table_fields(): + if parenttype and df.options != parenttype: + continue + value = self.get(df.fieldname) if isinstance(value, list): - ret.extend(value) - return ret + children.extend(value) + + return children def run_method(self, method, *args, **kwargs): """run standard triggers, plus those in hooks"""