diff --git a/erpnext/patches.txt b/erpnext/patches.txt index e4995f8203..c1d4b82baf 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -323,5 +323,6 @@ 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 migration patches should always run last -erpnext.patches.v14_0.migrate_gl_to_payment_ledger +erpnext.patches.v14_0.migrate_gl_to_payment_ledger \ No newline at end of file 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""" + )