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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. # metadata
  2. import webnotes
  3. #=================================================================================
  4. def get_dt_values(doctype, fields, as_dict = 0):
  5. return webnotes.conn.sql('SELECT %s FROM tabDocType WHERE name="%s"' % (fields, doctype), as_dict = as_dict)
  6. def set_dt_value(doctype, field, value):
  7. return webnotes.conn.set_value('DocType', doctype, field, value)
  8. def is_single(doctype):
  9. try:
  10. return get_dt_values(doctype, 'issingle')[0][0]
  11. except IndexError, e:
  12. raise Exception, 'Cannot determine whether %s is single' % doctype
  13. #=================================================================================
  14. def get_parent_dt(dt):
  15. parent_dt = webnotes.conn.sql('select parent from tabDocField where fieldtype="Table" and options="%s" and (parent not like "old_parent:%%") limit 1' % dt)
  16. return parent_dt and parent_dt[0][0] or ''
  17. #=================================================================================
  18. def set_fieldname(field_id, fieldname):
  19. webnotes.conn.set_value('DocField', field_id, 'fieldname', fieldname)
  20. #=================================================================================
  21. def get_link_fields(doctype):
  22. """
  23. Returns list of link fields for a doctype in tuple (fieldname, options, label)
  24. """
  25. return webnotes.conn.sql("""
  26. SELECT fieldname, options, label
  27. FROM tabDocField
  28. WHERE parent='%s'
  29. and (fieldtype='Link' or (fieldtype='Select' and `options` like 'link:%%'))
  30. and fieldname!='owner'""" % (doctype))
  31. #=================================================================================
  32. def get_table_fields(doctype):
  33. return webnotes.conn.sql("select options, fieldname from tabDocField where parent='%s' and fieldtype='Table'" % doctype)
  34. #=================================================================================
  35. def get_search_criteria(dt):
  36. import webnotes.model.doc
  37. # load search criteria for reports (all)
  38. dl = []
  39. sc_list = webnotes.conn.sql("select name from `tabSearch Criteria` where doc_type = '%s' or parent_doc_type = '%s' and (disabled!=1 OR disabled IS NULL)" % (dt, dt))
  40. for sc in sc_list:
  41. if sc[0]:
  42. dl += webnotes.model.doc.get('Search Criteria', sc[0])
  43. return dl
  44. #=================================================================================
  45. def get_print_format_html(name):
  46. html = webnotes.conn.sql('select html from `tabPrint Format` where name="%s"' % name)
  47. return html and html[0][0] or ''