fix(patch): updates maintenance schedule field for old docs

(cherry picked from commit c872aa43f8)

# Conflicts:
#	erpnext/patches.txt
This commit is contained in:
Noah Jacob
2021-12-15 15:27:41 +05:30
committed by mergify-bot
parent 8775154fa0
commit dc0d974144
2 changed files with 27 additions and 0 deletions

View File

@@ -336,8 +336,13 @@ erpnext.patches.v12_0.update_production_plan_status
erpnext.patches.v13_0.item_naming_series_not_mandatory
erpnext.patches.v13_0.update_category_in_ltds_certificate
erpnext.patches.v13_0.create_ksa_vat_custom_fields
<<<<<<< HEAD
erpnext.patches.v13_0.rename_ksa_qr_field
erpnext.patches.v13_0.disable_ksa_print_format_for_others # 16-12-2021
erpnext.patches.v13_0.update_tax_category_for_rcm
erpnext.patches.v13_0.convert_to_website_item_in_item_card_group_template
erpnext.patches.v13_0.agriculture_deprecation_warning
=======
erpnext.patches.v13_0.update_maintenance_schedule_field_in_visit
erpnext.patches.v14_0.migrate_crm_settings
>>>>>>> c872aa43f8 (fix(patch): updates maintenance schedule field for old docs)

View File

@@ -0,0 +1,22 @@
import frappe
def execute():
# Updates the Maintenance Schedule link to fetch serial nos
from frappe.query_builder.functions import Coalesce
mvp = frappe.qb.DocType('Maintenance Visit Purpose')
mv = frappe.qb.DocType('Maintenance Visit')
frappe.qb.update(
mv
).join(
mvp
).on(mvp.parent == mv.name).set(
mv.maintenance_schedule,
Coalesce(mvp.prevdoc_docname, '')
).where(
(mv.maintenance_type == "Scheduled")
& (mvp.prevdoc_docname.notnull())
& (mv.docstatus < 2)
).run(as_dict=1)