refactor: Move children load db into separate method
Signed-off-by: Gavin D'souza <gavin.dsouza@switchup.de>
This commit is contained in:
parent
60df96ce08
commit
b1d96dd532
1 changed files with 9 additions and 4 deletions
|
|
@ -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":
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue