-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28843 from noahjacob/maint_sch_link_fix
refactor: update_serial_no function for old Maintenance Visits
- Loading branch information
Showing
7 changed files
with
120 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
erpnext/patches/v13_0/update_maintenance_schedule_field_in_visit.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |