Procházet zdrojové kódy

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

version-14
Rushabh Mehta před 12 roky
rodič
revize
ca98b885f2
4 změnil soubory, kde provedl 17 přidání a 5 odebrání
  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 Zobrazit soubor

@@ -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'])


+ 3
- 0
public/css/ui/common.css Zobrazit soubor

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

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

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


+ 8
- 2
webnotes/model/doclist.py Zobrazit soubor

@@ -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):


+ 4
- 1
webnotes/model/mapper.py Zobrazit soubor

@@ -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:


Načítá se…
Zrušit
Uložit