fix(product bundle): fields reset if doc is new

This commit is contained in:
Mihir Kandoi
2025-11-20 11:49:55 +05:30
parent 0cb734d6a0
commit 7faee7edc2

View File

@@ -121,7 +121,12 @@ def get_indexed_packed_items_table(doc):
"""
indexed_table = {}
for packed_item in doc.get("packed_items"):
key = (packed_item.parent_item, packed_item.item_code, packed_item.parent_detail_docname)
key = (
packed_item.parent_item,
packed_item.item_code,
packed_item.idx if doc.is_new() else packed_item.parent_detail_docname,
)
indexed_table[key] = packed_item
return indexed_table
@@ -182,7 +187,11 @@ def add_packed_item_row(doc, packing_item, main_item_row, packed_items_table, re
exists, pi_row = False, {}
# check if row already exists in packed items table
key = (main_item_row.item_code, packing_item.item_code, main_item_row.name)
key = (
main_item_row.item_code,
packing_item.item_code,
main_item_row.idx if doc.is_new() else main_item_row.name,
)
if packed_items_table.get(key):
pi_row, exists = packed_items_table.get(key), True