From 58f6534d8b40a1f4d126fda4b6372ed1734dee13 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Sat, 2 Aug 2025 12:16:45 +0530 Subject: [PATCH] perf: process_gl_map causing performance issues in the reposting (cherry picked from commit a96fa557041dbc6be6d0b28b9da773db2a6b2ef7) --- erpnext/controllers/stock_controller.py | 4 +++- erpnext/stock/doctype/purchase_receipt/purchase_receipt.py | 2 +- erpnext/stock/doctype/stock_entry/stock_entry.py | 2 +- .../doctype/subcontracting_receipt/subcontracting_receipt.py | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/erpnext/controllers/stock_controller.py b/erpnext/controllers/stock_controller.py index 81cf7fb80d7..e375c2c362c 100644 --- a/erpnext/controllers/stock_controller.py +++ b/erpnext/controllers/stock_controller.py @@ -638,7 +638,9 @@ class StockController(AccountsController): ).format(wh, self.company) ) - return process_gl_map(gl_list, precision=precision) + return process_gl_map( + gl_list, precision=precision, from_repost=frappe.flags.through_repost_item_valuation + ) def get_debit_field_precision(self): if not frappe.flags.debit_field_precision: diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py index d9597fe413a..9e7dea631a9 100644 --- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py +++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py @@ -443,7 +443,7 @@ class PurchaseReceipt(BuyingController): self.make_tax_gl_entries(gl_entries, via_landed_cost_voucher) update_regional_gl_entries(gl_entries, self) - return process_gl_map(gl_entries) + return process_gl_map(gl_entries, from_repost=frappe.flags.through_repost_item_valuation) def make_item_gl_entries(self, gl_entries, warehouse_account=None): from erpnext.accounts.doctype.purchase_invoice.purchase_invoice import ( diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py index 37c0340d2bf..a1260c5ffdd 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -1612,7 +1612,7 @@ class StockEntry(StockController): ) ) - return process_gl_map(gl_entries) + return process_gl_map(gl_entries, from_repost=frappe.flags.through_repost_item_valuation) def update_work_order(self): def _validate_work_order(pro_doc): diff --git a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.py b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.py index 00c1c08cd5c..23a1ab9ebf4 100644 --- a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.py +++ b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.py @@ -548,7 +548,7 @@ class SubcontractingReceipt(SubcontractingController): gl_entries = [] self.make_item_gl_entries(gl_entries, warehouse_account) - return process_gl_map(gl_entries) + return process_gl_map(gl_entries, from_repost=frappe.flags.through_repost_item_valuation) def make_item_gl_entries(self, gl_entries, warehouse_account=None): warehouse_with_no_account = []