Merge pull request #32379 from sagarvora/fix-get-onload

fix(Document): improve `__onload` implementation
This commit is contained in:
Sagar Vora 2025-05-03 15:14:24 +00:00 committed by GitHub
commit f242b34ef2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1696,16 +1696,20 @@ class Document(BaseDocument, DocRef):
else:
return []
@property
def __onload(self):
onload = self.get("__onload")
if onload is None:
onload = frappe._dict()
self.set("__onload", onload)
return onload
def set_onload(self, key, value):
if not self.get("__onload"):
self.set("__onload", frappe._dict())
self.get("__onload")[key] = value
self.__onload[key] = value
def get_onload(self, key=None):
if not key:
return self.get("__onload", frappe._dict())
return self.get("__onload")[key]
return self.__onload[key] if key else self.__onload
def queue_action(self, action, **kwargs):
"""Run an action in background. If the action has an inner function,