@@ -109,9 +109,13 @@ class BaseDocument(object): | |||||
value.parent = self.name | value.parent = self.name | ||||
value.parenttype = self.doctype | value.parenttype = self.doctype | ||||
value.parentfield = key | value.parentfield = key | ||||
if not getattr(value, "idx", None): | if not getattr(value, "idx", None): | ||||
value.idx = len(self.get(key) or []) + 1 | value.idx = len(self.get(key) or []) + 1 | ||||
if not getattr(value, "name", None): | |||||
value.__dict__['__islocal'] = 1 | |||||
return value | return value | ||||
def get_valid_dict(self): | def get_valid_dict(self): | ||||
@@ -18,15 +18,9 @@ class DocListController(Document): | |||||
"""check that value of fieldname should be 'condition' val2 | """check that value of fieldname should be 'condition' val2 | ||||
else throw exception""" | else throw exception""" | ||||
error_condition_map = { | error_condition_map = { | ||||
"=": "!=", | |||||
"!=": "=", | |||||
"<": ">=", | |||||
">": "<=", | |||||
">=": "<", | |||||
"<=": ">", | |||||
"in": _("not in"), | |||||
"not in": _("in"), | |||||
"^": _("cannot start with"), | |||||
"in": _("one of"), | |||||
"not in": _("none of"), | |||||
"^": _("beginning with"), | |||||
} | } | ||||
if not doc: | if not doc: | ||||
@@ -49,7 +43,7 @@ class DocListController(Document): | |||||
if not frappe.compare(val1, condition, val2): | if not frappe.compare(val1, condition, val2): | ||||
label = doc.meta.get_label(fieldname) | label = doc.meta.get_label(fieldname) | ||||
condition_str = error_condition_map.get(condition, "") | |||||
condition_str = error_condition_map.get(condition, condition) | |||||
if doc.parentfield: | if doc.parentfield: | ||||
msg = _("Incorrect value in row {0}: {1} must be {2} {3}".format(doc.idx, label, condition_str, val2)) | msg = _("Incorrect value in row {0}: {1} must be {2} {3}".format(doc.idx, label, condition_str, val2)) | ||||
else: | else: | ||||
@@ -18,12 +18,6 @@ $.extend(frappe.model, { | |||||
var dirty = []; | var dirty = []; | ||||
$.each(r.docs, function(i, d) { | $.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); | frappe.model.add_to_locals(d); | ||||
d.__last_sync_on = new Date(); | d.__last_sync_on = new Date(); | ||||
@@ -68,8 +62,16 @@ $.extend(frappe.model, { | |||||
}, | }, | ||||
add_to_locals: function(doc) { | add_to_locals: function(doc) { | ||||
if(!locals[doc.doctype]) locals[doc.doctype] = {}; | 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; | locals[doc.doctype][doc.name] = doc; | ||||
if(!doc.parent) { | |||||
if(!doc.parentfield) { | |||||
$.each(doc, function(key, value) { | $.each(doc, function(key, value) { | ||||
if($.isArray(value)) { | if($.isArray(value)) { | ||||
$.each(value, function(i, d) { | $.each(value, function(i, d) { | ||||