def import_doc(d, doctype, overwrite, row_idx, submit=False, ignore_links=False):
 if (d.get(u'name') and frappe.db.exists(doctype, d[u'name'])):
  if overwrite:
   doc = frappe.get_doc(doctype, d[u'name'])
   doc.flags.ignore_links = ignore_links
   doc.update(d)
   if (d.get(u'docstatus') == 1):
    doc.update_after_submit()
   else:
    doc.save()
   return (u'Updated row (#%d) %s' % ((row_idx + 1), getlink(doctype, d[u'name'])))
  else:
   return (u'Ignored row (#%d) %s (exists)' % ((row_idx + 1), getlink(doctype, d[u'name'])))
 else:
  doc = frappe.get_doc(d)
  doc.flags.ignore_links = ignore_links
  doc.insert()
  if submit:
   doc.submit()
  return (u'Inserted row (#%d) %s' % ((row_idx + 1), getlink(doctype, doc.get(u'name'))))

def import_doc ( d , doctype , overwrite , row_idx , submit = False , ignore_links = False ) : if ( d . get ( u'name' ) and frappe . db . exists ( doctype , d [ u'name' ] ) ) : if overwrite : doc = frappe . get_doc ( doctype , d [ u'name' ] ) doc . flags . ignore_links = ignore_links doc . update ( d ) if ( d . get ( u'docstatus' ) == 1 ) : doc . update_after_submit ( ) else : doc . save ( ) return ( u'Updated row (#%d) %s' % ( ( row_idx + 1 ) , getlink ( doctype , d [ u'name' ] ) ) ) else : return ( u'Ignored row (#%d) %s (exists)' % ( ( row_idx + 1 ) , getlink ( doctype , d [ u'name' ] ) ) ) else : doc = frappe . get_doc ( d ) doc . flags . ignore_links = ignore_links doc . insert ( ) if submit : doc . submit ( ) return ( u'Inserted row (#%d) %s' % ( ( row_idx + 1 ) , getlink ( doctype , doc . get ( u'name' ) ) ) )
import a file using data import tool .