From ca98b885f23437bbe7325e8d4df26fe7ab16a4eb Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 6 Aug 2013 12:40:23 +0530 Subject: [PATCH] [mapper] [minor] idx fix for multiple pulls webnotes/erpnext#651 --- core/page/data_import_tool/data_import_tool.py | 4 ++-- public/css/ui/common.css | 3 +++ webnotes/model/doclist.py | 10 ++++++++-- webnotes/model/mapper.py | 5 ++++- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/core/page/data_import_tool/data_import_tool.py b/core/page/data_import_tool/data_import_tool.py index 9eda94cb15..cfbbbe787c 100644 --- a/core/page/data_import_tool/data_import_tool.py +++ b/core/page/data_import_tool/data_import_tool.py @@ -61,10 +61,10 @@ def get_template(): w.writerow(['Notes:']) w.writerow(['Please do not change the template headings.']) w.writerow(['First data column must be blank.']) - w.writerow(['Only mandatory fields are necessary for new records. You can delete non-mandatory columns if you wish.']) - w.writerow(['For updating, you can update only selective columns.']) w.writerow(['If you are uploading new records, leave the "name" (ID) column blank.']) w.writerow(['If you are uploading new records, "Naming Series" becomes mandatory, if present.']) + w.writerow(['Only mandatory fields are necessary for new records. You can delete non-mandatory columns if you wish.']) + w.writerow(['For updating, you can update only selective columns.']) w.writerow(['You can only upload upto 5000 records in one go. (may be less in some cases)']) if key == "parent": w.writerow(['"Parent" signifies the parent table in which this row must be added']) diff --git a/public/css/ui/common.css b/public/css/ui/common.css index 3fa486e7f0..a1a9a9a46e 100644 --- a/public/css/ui/common.css +++ b/public/css/ui/common.css @@ -373,6 +373,9 @@ div#freeze { outline: none; } +.wysiwyg-editor img { + max-width: 100%; +} /* form */ textarea[data-fieldtype="Small Text"] { diff --git a/webnotes/model/doclist.py b/webnotes/model/doclist.py index 46e1e4bcce..6d65a1b7db 100644 --- a/webnotes/model/doclist.py +++ b/webnotes/model/doclist.py @@ -6,7 +6,7 @@ import webnotes.model from webnotes.model.doc import Document class DocList(list): - """DocList object as a wrapper around a list""" + """DocList object as a wrapper around a list""" def get(self, filters, limit=0): """pass filters as: {"key": "val", "key": ["!=", "val"], @@ -63,6 +63,12 @@ class DocList(list): out.append(Document(fielddata=fielddata)) return DocList(out) + def get_item_value(self, d, name): + if isinstance(d, dict): + return d[name] + else: + return d.fields[name] + def filter_valid_fields(self): import webnotes.model fieldnames = {} @@ -101,7 +107,7 @@ class DocList(list): if not doc.parent: doc.parent = self[0].name if not doc.idx: - siblings = [int(d.idx or 0) for d in self.get({"parentfield": doc.parentfield})] + siblings = [int(self.get_item_value(d, "idx") or 0) for d in self.get({"parentfield": doc.parentfield})] doc.idx = (max(siblings) + 1) if siblings else 1 def objectify(doclist): diff --git a/webnotes/model/mapper.py b/webnotes/model/mapper.py index 327dcbea4d..e3d0050ea0 100644 --- a/webnotes/model/mapper.py +++ b/webnotes/model/mapper.py @@ -38,6 +38,8 @@ def get_mapped_doclist(from_doctype, from_docname, table_maps, target_doclist=No else: target_doclist = [target_doc] + target_doclist = webnotes.doclist(target_doclist) + # children for source_d in source.doclist[1:]: table_map = table_maps.get(source_d.doctype) @@ -58,8 +60,9 @@ def get_mapped_doclist(from_doctype, from_docname, table_maps, target_doclist=No target_d = webnotes.new_doc(target_doctype, target_doc, parentfield) map_doc(source_d, target_d, table_map, source_meta, target_meta, source.doclist[0]) + target_d.idx = None target_doclist.append(target_d) - + target_doclist = webnotes.doclist(target_doclist) if postprocess: