Browse Source

fix: show parent in `__repr__` only if available

version-14
Sagar Vora 3 years ago
parent
commit
d3f8f676d4
1 changed files with 2 additions and 4 deletions
  1. +2
    -4
      frappe/model/document.py

+ 2
- 4
frappe/model/document.py View File

@@ -1378,11 +1378,9 @@ class Document(BaseDocument):
doctype = self.__class__.__name__ doctype = self.__class__.__name__


docstatus = f" docstatus={self.docstatus}" if self.docstatus else "" docstatus = f" docstatus={self.docstatus}" if self.docstatus else ""
repr_str = f"<{doctype}: {name}{docstatus}"
parent = f" parent={self.parent}" if getattr(self, "parent", None) else ""


if not hasattr(self, "parent"):
return repr_str + ">"
return f"{repr_str} parent={self.parent}>"
return f"<{doctype}: {name}{docstatus}{parent}>"


def __str__(self): def __str__(self):
name = self.name or "unsaved" name = self.name or "unsaved"


Loading…
Cancel
Save