fix: child rows for cancelled docs in getdiff
This commit is contained in:
parent
0d80ffc988
commit
ef7af5e849
1 changed files with 14 additions and 2 deletions
|
|
@ -59,7 +59,7 @@ class Version(Document):
|
|||
return json.loads(self.data)
|
||||
|
||||
|
||||
def get_diff(old, new, for_child=False):
|
||||
def get_diff(old, new, for_child=False, compare_cancelled=False):
|
||||
"""Get diff between 2 document objects
|
||||
|
||||
If there is a change, then returns a dict like:
|
||||
|
|
@ -111,7 +111,19 @@ def get_diff(old, new, for_child=False):
|
|||
|
||||
# check rows for additions, changes
|
||||
for i, d in enumerate(new_value):
|
||||
old_row_name = getattr(d, old_row_name_field, None)
|
||||
old_row_name = None
|
||||
|
||||
if compare_cancelled:
|
||||
amended_from = frappe.db.get_value(d.parenttype, d.parent, "amended_from")
|
||||
if amended_from:
|
||||
parent_doc = frappe.get_doc(d.parenttype, amended_from)
|
||||
old_table = parent_doc.get(d.parentfield)
|
||||
if old_table and len(old_table) > i:
|
||||
old_row_name = old_table[i].name
|
||||
|
||||
if not old_row_name:
|
||||
old_row_name = getattr(d, old_row_name_field, None)
|
||||
|
||||
if old_row_name and old_row_name in old_rows_by_name:
|
||||
found_rows.add(old_row_name)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue