Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 
 

60 řádky
2.2 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 insert(doclist):
  27. if isinstance(doclist, basestring):
  28. doclist = json.loads(doclist)
  29. doclist[0]["__islocal"] = 1
  30. return save(doclist)
  31. @webnotes.whitelist()
  32. def save(doclist):
  33. """insert or update from form query"""
  34. if isinstance(doclist, basestring):
  35. doclist = json.loads(doclist)
  36. if not webnotes.has_permission(doclist[0]["doctype"], "write"):
  37. webnotes.msgprint("No Write Permission", raise_exception=True)
  38. doclistobj = webnotes.model_wrapper(doclist)
  39. doclistobj.save()
  40. return [d.fields for d in doclist]
  41. @webnotes.whitelist()
  42. def set_default(key, value, parent=None):
  43. """set a user default value"""
  44. webnotes.conn.set_default(key, value, parent or webnotes.session.user)
  45. webnotes.clear_cache(user=webnotes.session.user)
  46. @webnotes.whitelist()
  47. def make_width_property_setter():
  48. doclist = json.loads(webnotes.form_dict.doclist)
  49. if doclist[0]["doctype"]=="Property Setter" and doclist[0]["property"]=="width":
  50. webnotes.model_wrapper(doclist).save()