refactor(Work Order): query_sales_order

- Use `get_list` instead of `db.sql_list`

    The method is used for setting link options in the frontend and the Link field doesn't ignore permissions, so get_list should be fine here.

- Added type hints to enable argument validation
This commit is contained in:
barredterra
2025-06-09 22:15:41 +02:00
parent ffa014ecdc
commit 2dbdacf905

View File

@@ -1992,20 +1992,20 @@ def stop_unstop(work_order, status):
@frappe.whitelist()
def query_sales_order(production_item):
out = frappe.db.sql_list(
"""
select distinct so.name from `tabSales Order` so, `tabSales Order Item` so_item
where so_item.parent=so.name and so_item.item_code=%s and so.docstatus=1
union
select distinct so.name from `tabSales Order` so, `tabPacked Item` pi_item
where pi_item.parent=so.name and pi_item.item_code=%s and so.docstatus=1
""",
(production_item, production_item),
def query_sales_order(production_item: str) -> list[str]:
return frappe.get_list(
"Sales Order",
filters=[
["Sales Order", "docstatus", "=", 1],
],
or_filters=[
["Sales Order Item", "item_code", "=", production_item],
["Packed Item", "item_code", "=", production_item],
],
pluck="name",
distinct=True,
)
return out
@frappe.whitelist()
def make_job_card(work_order, operations):