diff --git a/frappe/model/document.py b/frappe/model/document.py index 4afeb56542..0e582a8616 100644 --- a/frappe/model/document.py +++ b/frappe/model/document.py @@ -255,6 +255,15 @@ class Document(BaseDocument): super().__init__(d) self.flags.pop("ignore_children", None) + self.load_children_from_db() + + # sometimes __setup__ can depend on child values, hence calling again at the end + if hasattr(self, "__setup__"): + self.__setup__() + + return self + + def load_children_from_db(self): for df in self._get_table_fields(): # Make sure not to query the DB for a child table, if it is a virtual one. # During frappe is installed, the property "is_virtual" is not available in tabDocType, so @@ -277,10 +286,6 @@ class Document(BaseDocument): self.set(df.fieldname, children) - # sometimes __setup__ can depend on child values, hence calling again at the end - if hasattr(self, "__setup__"): - self.__setup__() - return self def reload(self) -> "Self":