From a8a8ac71b62b14617cb19ef8ca2596c77a56fac9 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Thu, 9 Jan 2025 20:05:30 +0530 Subject: [PATCH] refactor: patch to migrate checkbox to select --- erpnext/patches.txt | 3 ++- ...kbox_to_select_for_reconciliation_effect.py | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 erpnext/patches/v15_0/migrate_checkbox_to_select_for_reconciliation_effect.py diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 29739a4e01f..4c650ac05cf 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -394,4 +394,5 @@ erpnext.patches.v14_0.update_stock_uom_in_work_order_item erpnext.patches.v15_0.enable_allow_existing_serial_no erpnext.patches.v15_0.update_cc_in_process_statement_of_accounts erpnext.patches.v15_0.refactor_closing_stock_balance #5 -erpnext.patches.v15_0.update_asset_status_to_work_in_progress \ No newline at end of file +erpnext.patches.v15_0.update_asset_status_to_work_in_progress +erpnext.patches.v15_0.migrate_checkbox_to_select_for_reconciliation_effect diff --git a/erpnext/patches/v15_0/migrate_checkbox_to_select_for_reconciliation_effect.py b/erpnext/patches/v15_0/migrate_checkbox_to_select_for_reconciliation_effect.py new file mode 100644 index 00000000000..883921cfdf8 --- /dev/null +++ b/erpnext/patches/v15_0/migrate_checkbox_to_select_for_reconciliation_effect.py @@ -0,0 +1,18 @@ +import frappe + + +def execute(): + """ + A New select field 'reconciliation_takes_effect_on' has been added to control Advance Payment Reconciliation dates. + Migrate old checkbox configuration to new select field on 'Company' and 'Payment Entry' + """ + companies = frappe.db.get_all("Company", fields=["name", "reconciliation_takes_effect_on"]) + for x in companies: + new_value = ( + "Advance Payment Date" if x.reconcile_on_advance_payment_date else "Oldest Of Invoice Or Advance" + ) + frappe.db.set_value("Company", x.name, "reconciliation_takes_effect_on", new_value) + + frappe.db.sql( + """update `tabPayment Entry` set advance_reconciliation_takes_effect_on = if(reconcile_on_advance_payment_date = 0, 'Oldest Of Invoice Or Advance', 'Advance Payment Date')""" + )