Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

moduleview.py 1.3 KiB

pirms 12 gadiem
pirms 12 gadiem
pirms 12 gadiem
pirms 12 gadiem
pirms 12 gadiem
pirms 12 gadiem
pirms 12 gadiem
pirms 12 gadiem
pirms 12 gadiem
12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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, json
  5. from webnotes.widgets import reportview
  6. @webnotes.whitelist()
  7. def get_data(module, doctypes='[]'):
  8. doctypes = json.loads(doctypes)
  9. return {
  10. "reports": get_report_list(module),
  11. "item_count": get_count(doctypes)
  12. }
  13. def get_count(doctypes):
  14. count = {}
  15. can_read = webnotes.user.get_can_read()
  16. for d in doctypes:
  17. if d in can_read:
  18. count[d] = get_doctype_count_from_table(d)
  19. return count
  20. def get_doctype_count_from_table(doctype):
  21. try:
  22. count = reportview.execute(doctype, fields=["count(*)"], as_list=True)[0][0]
  23. except Exception, e:
  24. if e.args[0]==1146:
  25. count = None
  26. else:
  27. raise
  28. return count
  29. def get_report_list(module):
  30. """return list on new style reports for modules"""
  31. return webnotes.conn.sql("""
  32. select distinct tabReport.name, tabReport.ref_doctype as doctype,
  33. if((tabReport.report_type='Query Report' or
  34. tabReport.report_type='Script Report'), 1, 0) as is_query_report
  35. from `tabReport`, `tabDocType`
  36. where tabDocType.module=%s
  37. and tabDocType.name = tabReport.ref_doctype
  38. and tabReport.docstatus in (0, NULL)
  39. and ifnull(tabReport.is_standard, "No")="No"
  40. and ifnull(tabReport.disabled,0) != 1
  41. order by tabReport.name""", module, as_dict=True)