def add_data(): def add_data_row(row_group, dt, doc, rowidx): d = doc.copy() if all_doctypes: d.name = '"'+ d.name+'"' if len(row_group) < rowidx + 1: row_group.append([""] * (len(columns) + 1)) row = row_group[rowidx] for i, c in enumerate(columns[column_start_end[dt].start:column_start_end[dt].end]): row[column_start_end[dt].start + i + 1] = d.get(c, "") if with_data=='Yes': webnotes.permissions.can_export(parent_doctype, raise_exception=True) # get permitted data only data = reportview.execute(doctype, fields="*") for doc in data: # add main table row_group = [] add_data_row(row_group, doctype, doc, 0) if all_doctypes: # add child tables for child_doctype in child_doctypes: for ci, child in enumerate(webnotes.conn.sql("""select * from `tab%s` where parent=%s order by idx""" % (child_doctype, "%s"), doc.name, as_dict=1)): add_data_row(row_group, child_doctype, child, ci) for row in row_group: w.writerow(row)
def get_doctype_count_from_table(doctype): try: count = reportview.execute(doctype, fields=["count(*)"], as_list=True)[0][0] except Exception, e: if e.args[0]==1146: count = None else: raise
def get_doctype_count_from_table(doctype): try: count = reportview.execute(doctype, fields=["count(*)"], as_list=True)[0][0] except Exception, e: if e.args[0] == 1146: count = None else: raise