Merge pull request #34392 from AnandBaburajan/patch_assdeprsch_gpa_ndb

fix: add missing patch for new fields added in #34214
This commit is contained in:
Anand Baburajan 2023-03-14 12:18:29 +05:30 committed by GitHub
commit fe672aa9b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 1 deletions

View File

@ -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

View File

@ -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"""
)