fix(Document): improve __onload implementation
This commit is contained in:
parent
42f1d1b460
commit
f93b87ddd8
1 changed files with 11 additions and 7 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue