fix(ux): remove get item buttons from submitted production plan (#30224)

(cherry picked from commit 1af13ca4bf)

fix(patch): remove dead links to ProdPlan Item

(cherry picked from commit d3e90ed8c8)

Co-authored-by: Ankush Menat <ankush@frappe.io>
This commit is contained in:
mergify[bot]
2022-03-14 15:17:46 +05:30
committed by GitHub
parent 468964a3f7
commit 2e79c4fd59
3 changed files with 45 additions and 3 deletions

View File

@@ -0,0 +1,37 @@
import frappe
def execute():
"""
Remove "production_plan_item" field where linked field doesn't exist in tha table.
"""
frappe.reload_doc("manufacturing", "doctype", "production_plan_item")
work_order = frappe.qb.DocType("Work Order")
pp_item = frappe.qb.DocType("Production Plan Item")
broken_work_orders = (
frappe.qb
.from_(work_order)
.left_join(pp_item).on(work_order.production_plan_item == pp_item.name)
.select(work_order.name)
.where(
(work_order.docstatus == 0)
& (work_order.production_plan_item.notnull())
& (work_order.production_plan_item.like("new-production-plan%"))
& (pp_item.name.isnull())
)
).run()
if not broken_work_orders:
return
broken_work_order_names = [d[0] for d in broken_work_orders]
(frappe.qb
.update(work_order)
.set(work_order.production_plan_item, None)
.where(work_order.name.isin(broken_work_order_names))
).run()