Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 
 

81 wiersze
2.6 KiB

  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. import json
  25. @webnotes.whitelist()
  26. def get(doctype, name=None, filters=None):
  27. if filters and not name:
  28. name = webnotes.conn.get_value(doctype, json.loads(filters))
  29. if not name:
  30. raise Exception, "No document found for given filters"
  31. return [d.fields for d in webnotes.bean(doctype, name).doclist]
  32. @webnotes.whitelist()
  33. def insert(doclist):
  34. if isinstance(doclist, basestring):
  35. doclist = json.loads(doclist)
  36. doclist[0]["__islocal"] = 1
  37. return save(doclist)
  38. @webnotes.whitelist()
  39. def save(doclist):
  40. if isinstance(doclist, basestring):
  41. doclist = json.loads(doclist)
  42. doclistobj = webnotes.bean(doclist)
  43. doclistobj.save()
  44. return [d.fields for d in doclist]
  45. @webnotes.whitelist()
  46. def submit(doclist):
  47. if isinstance(doclist, basestring):
  48. doclist = json.loads(doclist)
  49. doclistobj = webnotes.bean(doclist)
  50. doclistobj.submit()
  51. return [d.fields for d in doclist]
  52. @webnotes.whitelist()
  53. def cancel(doctype, name):
  54. wrapper = webnotes.bean(doctype, name)
  55. wrapper.cancel()
  56. return [d.fields for d in wrapper.doclist]
  57. @webnotes.whitelist()
  58. def set_default(key, value, parent=None):
  59. """set a user default value"""
  60. webnotes.conn.set_default(key, value, parent or webnotes.session.user)
  61. webnotes.clear_cache(user=webnotes.session.user)
  62. @webnotes.whitelist()
  63. def make_width_property_setter():
  64. doclist = json.loads(webnotes.form_dict.doclist)
  65. if doclist[0]["doctype"]=="Property Setter" and doclist[0]["property"]=="width":
  66. webnotes.bean(doclist).save()