From 9c72c2a6cb11197b292b0f589f312e038ac5cc3a Mon Sep 17 00:00:00 2001 From: Sagar Sharma Date: Fri, 12 May 2023 11:46:32 +0530 Subject: [PATCH] refactor: use `calculate_items_qty_and_amount()` to update scr items rate --- erpnext/stock/stock_ledger.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/erpnext/stock/stock_ledger.py b/erpnext/stock/stock_ledger.py index aa272cbfa7..c7f0acd453 100644 --- a/erpnext/stock/stock_ledger.py +++ b/erpnext/stock/stock_ledger.py @@ -785,13 +785,15 @@ class update_entries_after(object): frappe.db.set_value("Subcontracting Receipt Item", sle.voucher_detail_no, "rate", outgoing_rate) else: frappe.db.set_value( - "Subcontracting Receipt Supplied Item", sle.voucher_detail_no, "rate", outgoing_rate + "Subcontracting Receipt Supplied Item", + sle.voucher_detail_no, + {"rate": outgoing_rate, "amount": abs(sle.actual_qty) * outgoing_rate}, ) scr = frappe.get_doc("Subcontracting Receipt", sle.voucher_no, for_update=True) - scr.set_missing_values() + scr.calculate_items_qty_and_amount() scr.db_update() - for d in scr.items + scr.get("supplied_items", []): + for d in scr.items: d.db_update() def get_serialized_values(self, sle):