fix: Update Product Bundle rate based on its updated amount
diff --git a/erpnext/stock/doctype/packed_item/packed_item.py b/erpnext/stock/doctype/packed_item/packed_item.py
index d2c07d2..ea963ed 100644
--- a/erpnext/stock/doctype/packed_item/packed_item.py
+++ b/erpnext/stock/doctype/packed_item/packed_item.py
@@ -137,6 +137,11 @@
current_parent_item_price = frappe.db.get_value(parent_items_doctype, parent_item_doc_name, 'amount')
if current_parent_item_price != bundle_price:
frappe.db.set_value(parent_items_doctype, parent_item_doc_name, 'amount', bundle_price)
+ update_parent_item_rate(parent_items_doctype, parent_item_doc_name, bundle_price)
+
+def update_parent_item_rate(parent_items_doctype, parent_item_doc_name, bundle_price):
+ parent_item_qty = frappe.db.get_value(parent_items_doctype, parent_item_doc_name, 'qty')
+ frappe.db.set_value(parent_items_doctype, parent_item_doc_name, 'rate', (bundle_price/parent_item_qty))
@frappe.whitelist()
def get_items_from_product_bundle(args):