mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-24 21:52:21 +01:00
perf: too many writes error during reposting (#43978)
perf: too many writes error
(cherry picked from commit 134c24b9c5)
Co-authored-by: rohitwaghchaure <rohitw1991@gmail.com>
This commit is contained in:
@@ -1047,7 +1047,7 @@ class update_entries_after:
|
|||||||
rate = 0
|
rate = 0
|
||||||
# Material Transfer, Repack, Manufacturing
|
# Material Transfer, Repack, Manufacturing
|
||||||
if sle.voucher_type == "Stock Entry":
|
if sle.voucher_type == "Stock Entry":
|
||||||
self.recalculate_amounts_in_stock_entry(sle.voucher_no)
|
self.recalculate_amounts_in_stock_entry(sle.voucher_no, sle.voucher_detail_no)
|
||||||
rate = frappe.db.get_value("Stock Entry Detail", sle.voucher_detail_no, "valuation_rate")
|
rate = frappe.db.get_value("Stock Entry Detail", sle.voucher_detail_no, "valuation_rate")
|
||||||
# Sales and Purchase Return
|
# Sales and Purchase Return
|
||||||
elif sle.voucher_type in (
|
elif sle.voucher_type in (
|
||||||
@@ -1176,14 +1176,15 @@ class update_entries_after:
|
|||||||
|
|
||||||
# Update outgoing item's rate, recalculate FG Item's rate and total incoming/outgoing amount
|
# Update outgoing item's rate, recalculate FG Item's rate and total incoming/outgoing amount
|
||||||
if not sle.dependant_sle_voucher_detail_no:
|
if not sle.dependant_sle_voucher_detail_no:
|
||||||
self.recalculate_amounts_in_stock_entry(sle.voucher_no)
|
self.recalculate_amounts_in_stock_entry(sle.voucher_no, sle.voucher_detail_no)
|
||||||
|
|
||||||
def recalculate_amounts_in_stock_entry(self, voucher_no):
|
def recalculate_amounts_in_stock_entry(self, voucher_no, voucher_detail_no):
|
||||||
stock_entry = frappe.get_doc("Stock Entry", voucher_no, for_update=True)
|
stock_entry = frappe.get_doc("Stock Entry", voucher_no, for_update=True)
|
||||||
stock_entry.calculate_rate_and_amount(reset_outgoing_rate=False, raise_error_if_no_rate=False)
|
stock_entry.calculate_rate_and_amount(reset_outgoing_rate=False, raise_error_if_no_rate=False)
|
||||||
stock_entry.db_update()
|
stock_entry.db_update()
|
||||||
for d in stock_entry.items:
|
for d in stock_entry.items:
|
||||||
d.db_update()
|
if d.name == voucher_detail_no or (not d.s_warehouse and d.t_warehouse):
|
||||||
|
d.db_update()
|
||||||
|
|
||||||
def update_rate_on_delivery_and_sales_return(self, sle, outgoing_rate):
|
def update_rate_on_delivery_and_sales_return(self, sle, outgoing_rate):
|
||||||
# Update item's incoming rate on transaction
|
# Update item's incoming rate on transaction
|
||||||
|
|||||||
Reference in New Issue
Block a user