Merge branch 'develop' into refactor/report/exponential-smoothing-forecasting
This commit is contained in:
commit
86c9ce9c20
@ -64,22 +64,21 @@ def get_columns(filters):
|
|||||||
|
|
||||||
|
|
||||||
def get_data(filters):
|
def get_data(filters):
|
||||||
cond = "1=1"
|
wo = frappe.qb.DocType("Work Order")
|
||||||
|
query = (
|
||||||
|
frappe.qb.from_(wo)
|
||||||
|
.select(wo.name.as_("work_order"), wo.qty, wo.produced_qty, wo.production_item, wo.bom_no)
|
||||||
|
.where((wo.produced_qty > wo.qty) & (wo.docstatus == 1))
|
||||||
|
)
|
||||||
|
|
||||||
if filters.get("bom_no") and not filters.get("work_order"):
|
if filters.get("bom_no") and not filters.get("work_order"):
|
||||||
cond += " and bom_no = '%s'" % filters.get("bom_no")
|
query = query.where(wo.bom_no == filters.get("bom_no"))
|
||||||
|
|
||||||
if filters.get("work_order"):
|
if filters.get("work_order"):
|
||||||
cond += " and name = '%s'" % filters.get("work_order")
|
query = query.where(wo.name == filters.get("work_order"))
|
||||||
|
|
||||||
results = []
|
results = []
|
||||||
for d in frappe.db.sql(
|
for d in query.run(as_dict=True):
|
||||||
""" select name as work_order, qty, produced_qty, production_item, bom_no
|
|
||||||
from `tabWork Order` where produced_qty > qty and docstatus = 1 and {0}""".format(
|
|
||||||
cond
|
|
||||||
),
|
|
||||||
as_dict=1,
|
|
||||||
):
|
|
||||||
results.append(d)
|
results.append(d)
|
||||||
|
|
||||||
for data in frappe.get_all(
|
for data in frappe.get_all(
|
||||||
@ -95,16 +94,17 @@ def get_data(filters):
|
|||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
@frappe.validate_and_sanitize_search_inputs
|
@frappe.validate_and_sanitize_search_inputs
|
||||||
def get_work_orders(doctype, txt, searchfield, start, page_len, filters):
|
def get_work_orders(doctype, txt, searchfield, start, page_len, filters):
|
||||||
cond = "1=1"
|
wo = frappe.qb.DocType("Work Order")
|
||||||
if filters.get("bom_no"):
|
query = (
|
||||||
cond += " and bom_no = '%s'" % filters.get("bom_no")
|
frappe.qb.from_(wo)
|
||||||
|
.select(wo.name)
|
||||||
return frappe.db.sql(
|
.where((wo.name.like(f"{txt}%")) & (wo.produced_qty > wo.qty) & (wo.docstatus == 1))
|
||||||
"""select name from `tabWork Order`
|
.orderby(wo.name)
|
||||||
where name like %(name)s and {0} and produced_qty > qty and docstatus = 1
|
.limit(page_len)
|
||||||
order by name limit {2} offset {1}""".format(
|
.offset(start)
|
||||||
cond, start, page_len
|
|
||||||
),
|
|
||||||
{"name": "%%%s%%" % txt},
|
|
||||||
as_list=1,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if filters.get("bom_no"):
|
||||||
|
query = query.where(wo.bom_no == filters.get("bom_no"))
|
||||||
|
|
||||||
|
return query.run(as_list=True)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user