From dc7b13ceef466baad6125bebc5883defa11dfa7f Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 6 Jul 2015 16:59:38 +0530 Subject: [PATCH] [hot] [fix] target doctype --- frappe/model/mapper.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/frappe/model/mapper.py b/frappe/model/mapper.py index c956716708..56677fb528 100644 --- a/frappe/model/mapper.py +++ b/frappe/model/mapper.py @@ -33,15 +33,16 @@ def get_mapped_doc(from_doctype, from_docname, table_maps, target_doc=None, for df in source_doc.meta.get_table_fields(): source_child_doctype = df.options table_map = table_maps.get(source_child_doctype) - + # if table_map isn't explicitly specified check if both source and target have the same fieldname and same table options and both of them don't have no_copy if not table_map: target_df = target_doc.meta.get_field(df.fieldname) - target_child_doctype = target_df.options - if target_df and target_child_doctype==source_child_doctype and not df.no_copy and not target_df.no_copy: - table_map = { - "doctype": target_child_doctype - } + if target_df: + target_child_doctype = target_df.options + if target_df and target_child_doctype==source_child_doctype and not df.no_copy and not target_df.no_copy: + table_map = { + "doctype": target_child_doctype + } if table_map: for source_d in source_doc.get(df.fieldname):