From ebb69532740bff99ce8886b4e04ed18545b20897 Mon Sep 17 00:00:00 2001 From: anandbaburajan Date: Thu, 9 Mar 2023 17:55:27 +0530 Subject: [PATCH] fix: add missing patch for new fields added in #34214 --- erpnext/patches.txt | 1 + .../update_gpa_and_ndb_for_assdeprsch.py | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 erpnext/patches/v15_0/update_gpa_and_ndb_for_assdeprsch.py diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 2abd65b1b5..b1cb0408cb 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -323,6 +323,7 @@ erpnext.patches.v14_0.update_entry_type_for_journal_entry erpnext.patches.v14_0.change_autoname_for_tax_withheld_vouchers erpnext.patches.v14_0.set_pick_list_status erpnext.patches.v15_0.update_asset_value_for_manual_depr_entries +erpnext.patches.v15_0.update_gpa_and_ndb_for_assdeprsch # below 2 migration patches should always run last erpnext.patches.v14_0.migrate_gl_to_payment_ledger erpnext.patches.v14_0.migrate_remarks_from_gl_to_payment_ledger diff --git a/erpnext/patches/v15_0/update_gpa_and_ndb_for_assdeprsch.py b/erpnext/patches/v15_0/update_gpa_and_ndb_for_assdeprsch.py new file mode 100644 index 0000000000..afb59e0f6f --- /dev/null +++ b/erpnext/patches/v15_0/update_gpa_and_ndb_for_assdeprsch.py @@ -0,0 +1,20 @@ +import frappe + + +def execute(): + # not using frappe.qb because https://github.com/frappe/frappe/issues/20292 + frappe.db.sql( + """UPDATE `tabAsset Depreciation Schedule` + JOIN `tabAsset` + ON `tabAsset Depreciation Schedule`.`asset`=`tabAsset`.`name` + SET + `tabAsset Depreciation Schedule`.`gross_purchase_amount`=`tabAsset`.`gross_purchase_amount`, + `tabAsset Depreciation Schedule`.`number_of_depreciations_booked`=`tabAsset`.`number_of_depreciations_booked` + WHERE + ( + `tabAsset Depreciation Schedule`.`gross_purchase_amount`<>`tabAsset`.`gross_purchase_amount` + OR + `tabAsset Depreciation Schedule`.`number_of_depreciations_booked`<>`tabAsset`.`number_of_depreciations_booked` + ) + AND `tabAsset Depreciation Schedule`.`docstatus`<2""" + )