fix(patch): updates maintenance schedule field for old docs
This commit is contained in:
parent
4f52b86d7e
commit
c872aa43f8
@ -313,4 +313,5 @@ erpnext.patches.v13_0.update_category_in_ltds_certificate
|
|||||||
erpnext.patches.v13_0.create_pan_field_for_india #2
|
erpnext.patches.v13_0.create_pan_field_for_india #2
|
||||||
erpnext.patches.v14_0.delete_hub_doctypes
|
erpnext.patches.v14_0.delete_hub_doctypes
|
||||||
erpnext.patches.v13_0.create_ksa_vat_custom_fields
|
erpnext.patches.v13_0.create_ksa_vat_custom_fields
|
||||||
|
erpnext.patches.v13_0.update_maintenance_schedule_field_in_visit
|
||||||
erpnext.patches.v14_0.migrate_crm_settings
|
erpnext.patches.v14_0.migrate_crm_settings
|
||||||
|
@ -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)
|
Loading…
Reference in New Issue
Block a user