您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

77 行
2.1 KiB

  1. # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
  2. # MIT License. See license.txt
  3. from __future__ import unicode_literals
  4. import webnotes
  5. import json
  6. @webnotes.whitelist()
  7. def get(doctype, name=None, filters=None):
  8. if filters and not name:
  9. name = webnotes.conn.get_value(doctype, json.loads(filters))
  10. if not name:
  11. raise Exception, "No document found for given filters"
  12. return [d.fields for d in webnotes.bean(doctype, name).doclist]
  13. @webnotes.whitelist()
  14. def get_value(doctype, fieldname, filters=None, as_dict=True, debug=False):
  15. if not webnotes.has_permission(doctype):
  16. webnotes.msgprint("No Permission", raise_exception=True)
  17. if fieldname and fieldname.startswith("["):
  18. fieldname = json.loads(fieldname)
  19. return webnotes.conn.get_value(doctype, json.loads(filters), fieldname, as_dict=as_dict, debug=debug)
  20. @webnotes.whitelist()
  21. def insert(doclist):
  22. if isinstance(doclist, basestring):
  23. doclist = json.loads(doclist)
  24. doclist[0]["__islocal"] = 1
  25. return save(doclist)
  26. @webnotes.whitelist()
  27. def save(doclist):
  28. if isinstance(doclist, basestring):
  29. doclist = json.loads(doclist)
  30. doclistobj = webnotes.bean(doclist)
  31. doclistobj.save()
  32. return [d.fields for d in doclist]
  33. @webnotes.whitelist()
  34. def submit(doclist):
  35. if isinstance(doclist, basestring):
  36. doclist = json.loads(doclist)
  37. doclistobj = webnotes.bean(doclist)
  38. doclistobj.submit()
  39. return [d.fields for d in doclist]
  40. @webnotes.whitelist()
  41. def cancel(doctype, name):
  42. wrapper = webnotes.bean(doctype, name)
  43. wrapper.cancel()
  44. return [d.fields for d in wrapper.doclist]
  45. @webnotes.whitelist()
  46. def delete(doctype, name):
  47. webnotes.delete_doc(doctype, name)
  48. @webnotes.whitelist()
  49. def set_default(key, value, parent=None):
  50. """set a user default value"""
  51. webnotes.conn.set_default(key, value, parent or webnotes.session.user)
  52. webnotes.clear_cache(user=webnotes.session.user)
  53. @webnotes.whitelist()
  54. def make_width_property_setter():
  55. doclist = json.loads(webnotes.form_dict.doclist)
  56. if doclist[0]["doctype"]=="Property Setter" and doclist[0]["property"]=="width":
  57. bean = webnotes.bean(doclist)
  58. bean.ignore_permissions = True
  59. bean.insert()