Pārlūkot izejas kodu

fix: incorrect logic for parenttype parameter in `get_all_children`

version-14
Sagar Vora pirms 3 gadiem
vecāks
revīzija
76779e7452
1 mainītis faili ar 11 papildinājumiem un 8 dzēšanām
  1. +11
    -8
      frappe/model/document.py

+ 11
- 8
frappe/model/document.py Parādīt failu

@@ -848,16 +848,19 @@ class Document(BaseDocument):
frappe.CancelledLinkError) frappe.CancelledLinkError)


def get_all_children(self, parenttype=None): 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) value = self.get(df.fieldname)
if isinstance(value, list): if isinstance(value, list):
ret.extend(value)
return ret
children.extend(value)

return children


def run_method(self, method, *args, **kwargs): def run_method(self, method, *args, **kwargs):
"""run standard triggers, plus those in hooks""" """run standard triggers, plus those in hooks"""


Notiek ielāde…
Atcelt
Saglabāt