From 4f33ee01cf81bb1e4f4628e0538b9450c86d91e6 Mon Sep 17 00:00:00 2001 From: khushi8112 Date: Tue, 2 Dec 2025 14:24:27 +0530 Subject: [PATCH] fix: undo incorrect patch modification --- .../modify_invalid_gain_loss_gl_entries.py | 49 +++++++------------ 1 file changed, 17 insertions(+), 32 deletions(-) diff --git a/erpnext/patches/v13_0/modify_invalid_gain_loss_gl_entries.py b/erpnext/patches/v13_0/modify_invalid_gain_loss_gl_entries.py index 37dbd728636..8e58d79b928 100644 --- a/erpnext/patches/v13_0/modify_invalid_gain_loss_gl_entries.py +++ b/erpnext/patches/v13_0/modify_invalid_gain_loss_gl_entries.py @@ -10,17 +10,15 @@ def execute(): purchase_invoices = frappe.db.sql( """ select - PI.company, PI_ADV.parenttype as type, PI_ADV.parent as name + parenttype as type, parent as name from - `tabPurchase Invoice Advance` as PI_ADV join `tabPurchase Invoice` as PI - on - PI_ADV.parent = PI.name + `tabPurchase Invoice Advance` where - PI_ADV.ref_exchange_rate = 1 - and PI_ADV.docstatus = 1 - and ifnull(PI_ADV.exchange_gain_loss, 0) != 0 + ref_exchange_rate = 1 + and docstatus = 1 + and ifnull(exchange_gain_loss, 0) != 0 group by - PI_ADV.parent + parent """, as_dict=1, ) @@ -28,17 +26,15 @@ def execute(): sales_invoices = frappe.db.sql( """ select - SI.company, SI_ADV.parenttype as type, SI_ADV.parent as name + parenttype as type, parent as name from - `tabSales Invoice Advance` as SI_ADV join `tabSales Invoice` as SI - on - SI_ADV.parent = SI.name + `tabSales Invoice Advance` where - SI_ADV.ref_exchange_rate = 1 - and SI_ADV.docstatus = 1 - and ifnull(SI_ADV.exchange_gain_loss, 0) != 0 + ref_exchange_rate = 1 + and docstatus = 1 + and ifnull(exchange_gain_loss, 0) != 0 group by - SI_ADV.parent + parent """, as_dict=1, ) @@ -49,21 +45,11 @@ def execute(): message=json.dumps(purchase_invoices + sales_invoices, indent=2), ) - original_frozen_dates = {} + acc_frozen_upto = frappe.db.get_single_value("Accounts Settings", "acc_frozen_upto") + if acc_frozen_upto: + frappe.db.set_single_value("Accounts Settings", "acc_frozen_upto", None) for invoice in purchase_invoices + sales_invoices: - company = invoice.company - - # Unfreeze only once per company - if company not in original_frozen_dates: - accounts_frozen_till_date = frappe.get_cached_value( - "Company", company, "accounts_frozen_till_date" - ) - original_frozen_dates[company] = accounts_frozen_till_date - - if accounts_frozen_till_date: - frappe.db.set_value("Company", company, "accounts_frozen_till_date", None) - try: doc = frappe.get_doc(invoice.type, invoice.name) doc.docstatus = 2 @@ -78,6 +64,5 @@ def execute(): frappe.db.rollback() print(f"Failed to correct gl entries of {invoice.name}") - for company, frozen_date in original_frozen_dates.items(): - if frozen_date: - frappe.db.set_value("Company", company, "accounts_frozen_till_date", frozen_date) + if acc_frozen_upto: + frappe.db.set_single_value("Accounts Settings", "acc_frozen_upto", acc_frozen_upto)