From af7dc363e17496a8f15dc48d9f7d076a636b2484 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Sat, 2 Aug 2025 12:16:45 +0530 Subject: [PATCH 1/2] perf: process_gl_map causing performance issues in the reposting (cherry picked from commit a96fa557041dbc6be6d0b28b9da773db2a6b2ef7) # Conflicts: # erpnext/stock/doctype/stock_entry/stock_entry.py --- erpnext/controllers/stock_controller.py | 4 +++- erpnext/stock/doctype/purchase_receipt/purchase_receipt.py | 2 +- erpnext/stock/doctype/stock_entry/stock_entry.py | 4 ++++ .../doctype/subcontracting_receipt/subcontracting_receipt.py | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/erpnext/controllers/stock_controller.py b/erpnext/controllers/stock_controller.py index 750978b0847..3aef41911f9 100644 --- a/erpnext/controllers/stock_controller.py +++ b/erpnext/controllers/stock_controller.py @@ -663,7 +663,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 35f94df186d..9daff0d7353 100644 --- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py +++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py @@ -479,7 +479,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 bdf4adda656..4b40cd34c4f 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -1648,9 +1648,13 @@ class StockEntry(StockController): ) ) +<<<<<<< HEAD self.set_gl_entries_for_landed_cost_voucher(gl_entries, warehouse_account) return process_gl_map(gl_entries) +======= + return process_gl_map(gl_entries, from_repost=frappe.flags.through_repost_item_valuation) +>>>>>>> a96fa55704 (perf: process_gl_map causing performance issues in the reposting) def set_gl_entries_for_landed_cost_voucher(self, gl_entries, warehouse_account): landed_cost_entries = self.get_item_account_wise_lcv_entries() diff --git a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.py b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.py index 81c5adc16ef..949d1850053 100644 --- a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.py +++ b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.py @@ -574,7 +574,7 @@ class SubcontractingReceipt(SubcontractingController): self.make_item_gl_entries(gl_entries, warehouse_account) self.make_item_gl_entries_for_lcv(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 = [] From 67b95c4abfab7cdb928d5c8491a7d5915663aa44 Mon Sep 17 00:00:00 2001 From: rohitwaghchaure Date: Sun, 3 Aug 2025 16:21:45 +0530 Subject: [PATCH 2/2] chore: fix conflicts --- erpnext/stock/doctype/stock_entry/stock_entry.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py index 4b40cd34c4f..3602ee8997a 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -1648,13 +1648,9 @@ class StockEntry(StockController): ) ) -<<<<<<< HEAD self.set_gl_entries_for_landed_cost_voucher(gl_entries, warehouse_account) - return process_gl_map(gl_entries) -======= return process_gl_map(gl_entries, from_repost=frappe.flags.through_repost_item_valuation) ->>>>>>> a96fa55704 (perf: process_gl_map causing performance issues in the reposting) def set_gl_entries_for_landed_cost_voucher(self, gl_entries, warehouse_account): landed_cost_entries = self.get_item_account_wise_lcv_entries()