From 43ecbf2cfd0ecb02c76ce56093a156a2bd5fdb0a Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 21 Feb 2012 11:36:57 +0530 Subject: [PATCH] Error fixed in importing child data --- py/webnotes/model/import_docs.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/py/webnotes/model/import_docs.py b/py/webnotes/model/import_docs.py index 39a5095dc1..8e1465ac86 100644 --- a/py/webnotes/model/import_docs.py +++ b/py/webnotes/model/import_docs.py @@ -90,19 +90,25 @@ class CSVImport: def validate_fields(self, lb_list): self.msg.append('

Checking fieldnames for %s

' % self.dt_list[0]) - #if len(self.dt_list) > 1 and self.overwrite: - # self.msg.append('
Error: Overwrite is not possible for Document %s
' % self.dt_list[0]) - # self.validate_success = 0 - # return if self.overwrite and len(self.dt_list) == 1 and 'Name' != lb_list[0]: self.msg.append('
Error : At Row 4 and Column 1: To Overwrite fieldname should be Name
') self.validate_success = 0 return + # labelnames res = self.validate_success and [d[0] for d in sql("select label from tabDocField where parent='%s' and docstatus!=2 and ifnull(hidden,'') in ('',0)" % self.dt_list[0])] or [] - if len(self.dt_list) > 1 and self.dt_list[1]: + if self.dt_list[1] not in lb_list: + self.msg.append('
Error : At Row 4: There should be one column named "'+self.dt_list[1]+'"
') + self.validate_success = 0 + return + + if 'Name' in lb_list: + self.msg.append('
Error : At Row 4: "Name" column should not be there
') + self.validate_success = 0 + return + self.fields.append('parent') lb_list.pop(lb_list.index(self.dt_list[1]))