From b00451d97cdf256edf54477601935bbf36a5b4eb Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 4 Jul 2013 17:52:03 +0530 Subject: [PATCH] [mapper] sales order-sales invoice added condition --- webnotes/model/mapper.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/webnotes/model/mapper.py b/webnotes/model/mapper.py index 7c6fac4ce1..535cd22ad8 100644 --- a/webnotes/model/mapper.py +++ b/webnotes/model/mapper.py @@ -49,7 +49,11 @@ def get_mapped_doclist(from_doctype, from_docname, table_maps, target_doclist=[] # children for source_d in source.doclist[1:]: - target_doctype = table_maps[source_d.doctype]["doctype"] + table_map = table_maps[source_d.doctype] + if "condition" in table_map: + if not table_map["condition"](source_d): + continue + target_doctype = table_map["doctype"] parentfield = target_meta.get({ "parent": target_doc.doctype, "doctype": "DocField", @@ -58,7 +62,7 @@ def get_mapped_doclist(from_doctype, from_docname, table_maps, target_doclist=[] })[0].fieldname target_d = webnotes.new_doc(target_doctype, target_doc, parentfield) - map_doc(source_d, target_d, table_maps[source_d.doctype], source_meta, target_meta) + map_doc(source_d, target_d, table_map, source_meta, target_meta) doclist.append(target_d) if postprocess: