瀏覽代碼

[mapper] [minor] idx fix for multiple pulls webnotes/erpnext#651

version-14
Rushabh Mehta 12 年之前
父節點
當前提交
ca98b885f2
共有 4 個文件被更改,包括 17 次插入5 次删除
  1. +2
    -2
      core/page/data_import_tool/data_import_tool.py
  2. +3
    -0
      public/css/ui/common.css
  3. +8
    -2
      webnotes/model/doclist.py
  4. +4
    -1
      webnotes/model/mapper.py

+ 2
- 2
core/page/data_import_tool/data_import_tool.py 查看文件

@@ -61,10 +61,10 @@ def get_template():
w.writerow(['Notes:']) w.writerow(['Notes:'])
w.writerow(['Please do not change the template headings.']) w.writerow(['Please do not change the template headings.'])
w.writerow(['First data column must be blank.']) 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, leave the "name" (ID) column blank.'])
w.writerow(['If you are uploading new records, "Naming Series" becomes mandatory, if present.']) 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)']) w.writerow(['You can only upload upto 5000 records in one go. (may be less in some cases)'])
if key == "parent": if key == "parent":
w.writerow(['"Parent" signifies the parent table in which this row must be added']) w.writerow(['"Parent" signifies the parent table in which this row must be added'])


+ 3
- 0
public/css/ui/common.css 查看文件

@@ -373,6 +373,9 @@ div#freeze {
outline: none; outline: none;
} }


.wysiwyg-editor img {
max-width: 100%;
}
/* form */ /* form */


textarea[data-fieldtype="Small Text"] { textarea[data-fieldtype="Small Text"] {


+ 8
- 2
webnotes/model/doclist.py 查看文件

@@ -6,7 +6,7 @@ import webnotes.model
from webnotes.model.doc import Document from webnotes.model.doc import Document


class DocList(list): 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): def get(self, filters, limit=0):
"""pass filters as: """pass filters as:
{"key": "val", "key": ["!=", "val"], {"key": "val", "key": ["!=", "val"],
@@ -63,6 +63,12 @@ class DocList(list):
out.append(Document(fielddata=fielddata)) out.append(Document(fielddata=fielddata))
return DocList(out) 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): def filter_valid_fields(self):
import webnotes.model import webnotes.model
fieldnames = {} fieldnames = {}
@@ -101,7 +107,7 @@ class DocList(list):
if not doc.parent: if not doc.parent:
doc.parent = self[0].name doc.parent = self[0].name
if not doc.idx: 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 doc.idx = (max(siblings) + 1) if siblings else 1
def objectify(doclist): def objectify(doclist):


+ 4
- 1
webnotes/model/mapper.py 查看文件

@@ -38,6 +38,8 @@ def get_mapped_doclist(from_doctype, from_docname, table_maps, target_doclist=No
else: else:
target_doclist = [target_doc] target_doclist = [target_doc]
target_doclist = webnotes.doclist(target_doclist)
# children # children
for source_d in source.doclist[1:]: for source_d in source.doclist[1:]:
table_map = table_maps.get(source_d.doctype) 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) 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]) 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.append(target_d)
target_doclist = webnotes.doclist(target_doclist) target_doclist = webnotes.doclist(target_doclist)
if postprocess: if postprocess:


Loading…
取消
儲存