Browse Source

Fixes in sync.js and init child

version-14
Anand Doshi 11 years ago
parent
commit
c04ada7066
3 changed files with 17 additions and 17 deletions
  1. +4
    -0
      frappe/model/base_document.py
  2. +4
    -10
      frappe/model/controller.py
  3. +9
    -7
      frappe/public/js/frappe/model/sync.js

+ 4
- 0
frappe/model/base_document.py View File

@@ -109,9 +109,13 @@ class BaseDocument(object):
value.parent = self.name
value.parenttype = self.doctype
value.parentfield = key

if not getattr(value, "idx", None):
value.idx = len(self.get(key) or []) + 1

if not getattr(value, "name", None):
value.__dict__['__islocal'] = 1

return value

def get_valid_dict(self):


+ 4
- 10
frappe/model/controller.py View File

@@ -18,15 +18,9 @@ class DocListController(Document):
"""check that value of fieldname should be 'condition' val2
else throw exception"""
error_condition_map = {
"=": "!=",
"!=": "=",
"<": ">=",
">": "<=",
">=": "<",
"<=": ">",
"in": _("not in"),
"not in": _("in"),
"^": _("cannot start with"),
"in": _("one of"),
"not in": _("none of"),
"^": _("beginning with"),
}

if not doc:
@@ -49,7 +43,7 @@ class DocListController(Document):

if not frappe.compare(val1, condition, val2):
label = doc.meta.get_label(fieldname)
condition_str = error_condition_map.get(condition, "")
condition_str = error_condition_map.get(condition, condition)
if doc.parentfield:
msg = _("Incorrect value in row {0}: {1} must be {2} {3}".format(doc.idx, label, condition_str, val2))
else:


+ 9
- 7
frappe/public/js/frappe/model/sync.js View File

@@ -18,12 +18,6 @@ $.extend(frappe.model, {
var dirty = [];

$.each(r.docs, function(i, d) {
if(!d.name && d.__islocal) { // get name (local if required)
frappe.model.clear_doc(d);
d.name = frappe.model.get_new_name(d.doctype);
frappe.provide("frappe.model.docinfo." + d.doctype + "." + d.name);
}

frappe.model.add_to_locals(d);
d.__last_sync_on = new Date();

@@ -68,8 +62,16 @@ $.extend(frappe.model, {
},
add_to_locals: function(doc) {
if(!locals[doc.doctype]) locals[doc.doctype] = {};
if(!doc.name && doc.__islocal) { // get name (local if required)
if(!doc.parentfield) frappe.model.clear_doc(doc);

doc.name = frappe.model.get_new_name(doc.doctype);

if(!doc.parentfield) frappe.provide("frappe.model.docinfo." + doc.doctype + "." + doc.name);
}
locals[doc.doctype][doc.name] = doc;
if(!doc.parent) {

if(!doc.parentfield) {
$.each(doc, function(key, value) {
if($.isArray(value)) {
$.each(value, function(i, d) {


Loading…
Cancel
Save