Antony-PB

less_hour_request.py

Dec 14th, 2023
356
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. import frappe
  2. import time
  3. from frappe.model.document import Document
  4.  
  5. class LessHourRequest(Document):
  6.  
  7.  
  8. def validate(self):
  9. # self.set_publish_progress_bar()
  10. frappe.enqueue_doc(
  11. self.doctype,
  12. self.name,
  13. "set_publish_progress_bar", # name of the controller method
  14. queue="long",
  15. timeout=4000,
  16. param="My Discription"
  17. )
  18.  
  19.  
  20. def set_publish_progress_bar(self, **kwargs):
  21. for i in range(1,101):
  22. time.sleep(1)
  23. description = f"frappe.publish_realtime {i} and Keyword Argument {kwargs}"
  24. frappe.publish_realtime('custom_event', {'message': f'{i}% of the preocess done from 100%', 'current':i, 'total':100}, user=frappe.session.user)
  25. # frappe.publish_progress(i, title='Some title', description=description, doctype=self.doctype)
Advertisement
Add Comment
Please, Sign In to add comment