コード例 #1
0
ファイル: rename_tool.py プロジェクト: rohitw1991/erpnext
def upload(select_doctype=None, rows=None):
    from webnotes.utils.datautils import read_csv_content_from_uploaded_file
    from webnotes.modules import scrub
    from webnotes.model.rename_doc import rename_doc

    if not select_doctype:
        select_doctype = webnotes.form_dict.select_doctype

    if not rows:
        rows = read_csv_content_from_uploaded_file()
    if not rows:
        webnotes.msgprint(_("Please select a valid csv file with data."))
        raise Exception

    if len(rows) > 500:
        webnotes.msgprint(_("Max 500 rows only."))
        raise Exception

    rename_log = []
    for row in rows:
        # if row has some content
        if len(row) > 1 and row[0] and row[1]:
            try:
                if rename_doc(select_doctype, row[0], row[1]):
                    rename_log.append(
                        _("Successful: ") + row[0] + " -> " + row[1])
                    webnotes.conn.commit()
                else:
                    rename_log.append(
                        _("Ignored: ") + row[0] + " -> " + row[1])
            except Exception, e:
                rename_log.append("<span style='color: RED'>" + \
                 _("Failed: ") + row[0] + " -> " + row[1] + "</span>")
                rename_log.append("<span style='margin-left: 20px;'>" +
                                  repr(e) + "</span>")
コード例 #2
0
def upload(select_doctype=None, rows=None):
	from webnotes.utils.datautils import read_csv_content_from_uploaded_file
	from webnotes.modules import scrub
	from webnotes.model.rename_doc import rename_doc

	if not select_doctype:
		select_doctype = webnotes.form_dict.select_doctype

	if not rows:
		rows = read_csv_content_from_uploaded_file()
	if not rows:
		webnotes.msgprint(_("Please select a valid csv file with data."))
		raise Exception
		
	if len(rows) > 500:
		webnotes.msgprint(_("Max 500 rows only."))
		raise Exception
	
	rename_log = []
	for row in rows:
		if len(row) > 2:
			try:
				if rename_doc(select_doctype, row[0], row[1]):
					rename_log.append(_("Successful: ") + row[0] + " -> " + row[1])
					webnotes.conn.commit()
				else:
					rename_log.append(_("Ignored: ") + row[0] + " -> " + row[1])
			except Exception, e:
				rename_log.append("<span style='color: RED'>" + \
					_("Failed: ") + row[0] + " -> " + row[1] + "</span>")
				rename_log.append("<span style='margin-left: 20px;'>" + repr(e) + "</span>")
コード例 #3
0
ファイル: __init__.py プロジェクト: IPenuelas/wnframework
def rename_doc(doctype, old, new, is_doctype=0, debug=0):
	from webnotes.model.rename_doc import rename_doc
	rename_doc(doctype, old, new, is_doctype, debug)
コード例 #4
0
ファイル: __init__.py プロジェクト: rohitw1991/latestadbwnf
def rename_doc(doctype, old, new, debug=0, force=False, merge=False):
	from webnotes.model.rename_doc import rename_doc
	rename_doc(doctype, old, new, force=force, merge=merge)
コード例 #5
0
def rename_doc(doctype, old, new, debug=0, force=False, merge=False):
    from webnotes.model.rename_doc import rename_doc
    return rename_doc(doctype, old, new, force=force, merge=merge)