From 129df6e129ec74e5d63a8b5f605a4561f0020e28 Mon Sep 17 00:00:00 2001 From: GangaManoj Date: Tue, 24 Aug 2021 21:55:54 +0530 Subject: [PATCH] fix: Update Product Bundle rate based on its updated amount --- erpnext/stock/doctype/packed_item/packed_item.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/erpnext/stock/doctype/packed_item/packed_item.py b/erpnext/stock/doctype/packed_item/packed_item.py index d2c07d2806..ea963ed8e8 100644 --- a/erpnext/stock/doctype/packed_item/packed_item.py +++ b/erpnext/stock/doctype/packed_item/packed_item.py @@ -137,6 +137,11 @@ def update_parent_item_price(doc, parent_items_doctype, parent_item_code, bundle 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):