You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

пре 11 година
пре 13 година
пре 13 година
пре 12 година
пре 12 година
пре 12 година
пре 12 година
пре 12 година
пре 12 година
пре 12 година
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
  2. # MIT License. See license.txt
  3. from __future__ import unicode_literals
  4. import webnotes
  5. @webnotes.whitelist()
  6. def savedocs():
  7. """save / submit / update doclist"""
  8. try:
  9. wrapper = webnotes.bean()
  10. wrapper.from_compressed(webnotes.form_dict.docs, webnotes.form_dict.docname)
  11. # action
  12. action = webnotes.form_dict.action
  13. if action=='Update': action='update_after_submit'
  14. try:
  15. getattr(wrapper, action.lower())()
  16. except NameError, e:
  17. webnotes.msgprint(webnotes._("Name Exists"))
  18. raise
  19. # update recent documents
  20. webnotes.user.update_recent(wrapper.doc.doctype, wrapper.doc.name)
  21. send_updated_docs(wrapper)
  22. except Exception, e:
  23. webnotes.msgprint(webnotes._('Did not save'))
  24. webnotes.errprint(webnotes.utils.getTraceback())
  25. raise
  26. @webnotes.whitelist()
  27. def cancel(doctype=None, name=None):
  28. """cancel a doclist"""
  29. try:
  30. wrapper = webnotes.bean(doctype, name)
  31. wrapper.cancel()
  32. send_updated_docs(wrapper)
  33. except Exception, e:
  34. webnotes.errprint(webnotes.utils.getTraceback())
  35. webnotes.msgprint(webnotes._("Did not cancel"))
  36. raise
  37. def send_updated_docs(wrapper):
  38. from load import set_docinfo
  39. set_docinfo(wrapper.doc.doctype, wrapper.doc.name)
  40. webnotes.response['main_doc_name'] = wrapper.doc.name
  41. webnotes.response['doctype'] = wrapper.doc.doctype
  42. webnotes.response['docname'] = wrapper.doc.name
  43. webnotes.response['docs'] = wrapper.doclist