Have been a long time, that I didn’t publish one hack for frappe!
Right now, I’m publising an hack, that I was wishing make, have some years!, They are a syntax sugar for links, that respect the serialization process
doc.as_json(), and also mimic “Nullable Strings”, (strings that may can be None)
There is the code: https://gist.github.com/MaxMorais/9ae255a7df742cff4d3adb58a0daea70
Of course it don’t solve all situations, frappe doctype will continue treating links as strings, ERPNext doctypes also.
The advantage of this process, is speed up, the development process, preventing developers to write all the time:
if frappe.db.exists('DocType X', self.link_x):
x_doc = frappe.get_doc('DocType X', self.link_x)
self.something = x_doc.do_something()
While you can do:
self.something = self.link_x and self.link_x.do_something()
Note: This hack may cannot be usefull for
NestedSet's due it still not lazy for now, so it will query all the tree.