From 827acd297539ec9c5210cb23c1538fb02926ddda Mon Sep 17 00:00:00 2001 From: Ninad1306 Date: Fri, 23 Aug 2024 12:47:08 +0530 Subject: [PATCH] fix: update child table value from the last doc --- frappe/model/mapper.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/frappe/model/mapper.py b/frappe/model/mapper.py index 5b727d8593..33ef91a90a 100644 --- a/frappe/model/mapper.py +++ b/frappe/model/mapper.py @@ -129,6 +129,12 @@ def get_mapped_doc( table_map = {"doctype": target_child_doctype} if table_map: + target_child_doctype = table_map["doctype"] + target_parentfield = target_doc.get_parentfield_of_doctype(target_child_doctype) + + if table_map.get("reset_value"): + setattr(target_doc, target_parentfield, []) + for source_d in source_doc.get(df.fieldname): if "condition" in table_map: if not table_map["condition"](source_d): @@ -143,9 +149,6 @@ def get_mapped_doc( ): continue - target_child_doctype = table_map["doctype"] - target_parentfield = target_doc.get_parentfield_of_doctype(target_child_doctype) - # does row exist for a parentfield? if target_parentfield not in row_exists_for_parentfield: row_exists_for_parentfield[target_parentfield] = (