From ccf84ae88a752d94d459e369fa5c1afaab9e49f1 Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Sun, 7 Nov 2021 18:06:37 +0530 Subject: [PATCH] fix: patch to update job card status --- erpnext/patches.txt | 1 + .../patches/v13_0/update_job_card_status.py | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 erpnext/patches/v13_0/update_job_card_status.py diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 1006e2180f..778cbdf65b 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -303,6 +303,7 @@ erpnext.patches.v13_0.set_status_in_maintenance_schedule_table erpnext.patches.v13_0.add_default_interview_notification_templates erpnext.patches.v13_0.enable_scheduler_job_for_item_reposting erpnext.patches.v13_0.requeue_failed_reposts +erpnext.patches.v13_0.update_job_card_status erpnext.patches.v12_0.update_production_plan_status erpnext.patches.v13_0.healthcare_deprecation_warning erpnext.patches.v14_0.delete_healthcare_doctypes diff --git a/erpnext/patches/v13_0/update_job_card_status.py b/erpnext/patches/v13_0/update_job_card_status.py new file mode 100644 index 0000000000..797a3e2ae3 --- /dev/null +++ b/erpnext/patches/v13_0/update_job_card_status.py @@ -0,0 +1,18 @@ +# Copyright (c) 2021, Frappe and Contributors +# License: GNU General Public License v3. See license.txt + +import frappe + + +def execute(): + + job_card = frappe.qb.DocType("Job Card") + (frappe.qb + .update(job_card) + .set(job_card.status, "Completed") + .where( + (job_card.docstatus == 1) + & (job_card.for_quantity <= job_card.total_completed_qty) + & (job_card.status.isin(["Work In Progress", "Material Transferred"])) + ) + ).run()