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.

пре 13 година
пре 13 година
пре 12 година
пре 12 година
пре 12 година
пре 12 година
пре 12 година
пре 12 година
пре 12 година
пре 12 година
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. # Copyright (c) 2012 Web Notes Technologies Pvt Ltd (http://erpnext.com)
  2. #
  3. # MIT License (MIT)
  4. #
  5. # Permission is hereby granted, free of charge, to any person obtaining a
  6. # copy of this software and associated documentation files (the "Software"),
  7. # to deal in the Software without restriction, including without limitation
  8. # the rights to use, copy, modify, merge, publish, distribute, sublicense,
  9. # and/or sell copies of the Software, and to permit persons to whom the
  10. # Software is furnished to do so, subject to the following conditions:
  11. #
  12. # The above copyright notice and this permission notice shall be included in
  13. # all copies or substantial portions of the Software.
  14. #
  15. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  16. # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  17. # PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  18. # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
  19. # CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
  20. # OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  21. #
  22. from __future__ import unicode_literals
  23. import webnotes
  24. @webnotes.whitelist()
  25. def savedocs():
  26. """save / submit / update doclist"""
  27. try:
  28. doclist = webnotes.model_wrapper()
  29. doclist.from_compressed(webnotes.form_dict.docs, webnotes.form_dict.docname)
  30. # action
  31. action = webnotes.form_dict.action
  32. if action=='Update': action='update_after_submit'
  33. getattr(doclist, action.lower())()
  34. # update recent documents
  35. webnotes.user.update_recent(doclist.doc.doctype, doclist.doc.name)
  36. send_updated_docs(doclist)
  37. except Exception, e:
  38. webnotes.msgprint(webnotes._('Did not save'))
  39. webnotes.errprint(webnotes.utils.getTraceback())
  40. raise e
  41. @webnotes.whitelist()
  42. def cancel(doctype=None, name=None):
  43. """cancel a doclist"""
  44. try:
  45. doclist = webnotes.model_wrapper(doctype, name)
  46. doclist.cancel()
  47. send_updated_docs(doclist)
  48. except Exception, e:
  49. webnotes.errprint(webnotes.utils.getTraceback())
  50. webnotes.msgprint(webnotes._("Did not cancel"))
  51. raise e
  52. def send_updated_docs(doclist):
  53. webnotes.response['main_doc_name'] = doclist.doc.name
  54. webnotes.response['doctype'] = doclist.doc.doctype
  55. webnotes.response['docname'] = doclist.doc.name
  56. webnotes.response['docs'] = [doclist.doc] + doclist.children