[minor] added ignore_links in data_import_tool

This commit is contained in:
Rushabh Mehta 2013-09-13 15:29:21 +05:30
parent 300848740c
commit e831439d8b
5 changed files with 10 additions and 8 deletions

View file

@ -389,13 +389,13 @@ def upload(rows = None, submit_after_import=None, ignore_encoding_errors=False,
if len(doclist) > 1:
if overwrite:
bean = webnotes.bean(doctype, doclist[0]["name"])
bean.ignore_check_links = ignore_links
bean.ignore_links = ignore_links
bean.doclist.update(doclist)
bean.save()
ret.append('Updated row (#%d) %s' % (row_idx + 1, getlink(bean.doc.doctype, bean.doc.name)))
else:
bean = webnotes.bean(doclist)
bean.ignore_check_links = ignore_links
bean.ignore_links = ignore_links
bean.insert()
ret.append('Inserted row (#%d) %s' % (row_idx + 1, getlink(bean.doc.doctype, bean.doc.name)))
if submit_after_import:
@ -416,7 +416,7 @@ def upload(rows = None, submit_after_import=None, ignore_encoding_errors=False,
doc.parent), unicode(doc.idx)))
parent_list.append(doc.parent)
else:
ret.append(import_doc(doclist[0], doctype, overwrite, row_idx, submit_after_import))
ret.append(import_doc(doclist[0], doctype, overwrite, row_idx, submit_after_import, ignore_links))
except Exception, e:
error = True

View file

@ -26,7 +26,7 @@ class Bean:
self.obj = None
self.ignore_permissions = False
self.ignore_children_type = []
self.ignore_check_links = False
self.ignore_links = False
self.ignore_validate = False
self.ignore_fields = False
self.ignore_mandatory = False
@ -157,7 +157,7 @@ class Bean:
labels[self.to_docstatus], raise_exception=DocstatusTransitionError)
def check_links(self):
if self.ignore_check_links:
if self.ignore_links:
return
ref, err_list = {}, []
for d in self.doclist:

View file

@ -85,7 +85,7 @@ def import_doclist(doclist):
# reload_new
new_bean = webnotes.bean(doclist1)
new_bean.ignore_children_type = ignore
new_bean.ignore_check_links = True
new_bean.ignore_links = True
new_bean.ignore_validate = True
new_bean.ignore_permissions = True
new_bean.ignore_mandatory = True

View file

@ -126,11 +126,12 @@ def check_record(d, parenttype=None, doctype_dl=None):
elif val and docfield.fieldtype in ["Currency", "Float"]:
d[key] = flt(val)
def import_doc(d, doctype, overwrite, row_idx, submit=False):
def import_doc(d, doctype, overwrite, row_idx, submit=False, ignore_links=False):
"""import main (non child) document"""
if d.get("name") and webnotes.conn.exists(doctype, d['name']):
if overwrite:
bean = webnotes.bean(doctype, d['name'])
bean.ignore_links = ignore_links
bean.doc.fields.update(d)
if d.get("docstatus") == 1:
bean.update_after_submit()
@ -142,6 +143,7 @@ def import_doc(d, doctype, overwrite, row_idx, submit=False):
getlink(doctype, d['name']))
else:
bean = webnotes.bean([d])
bean.ignore_links = ignore_links
bean.insert()
if submit:

2
wnf.py
View file

@ -550,7 +550,7 @@ def run():
webnotes.conn.commit()
if f.endswith(".csv"):
from core.page.data_import_tool.data_import_tool import import_file_by_path
import_file_by_path(f)
import_file_by_path(f, ignore_links=True)
webnotes.conn.commit()
elif options.reset_perms: