Merge pull request #23061 from DeeMysterio/dev-sort-warehouses-qty
feat(queries): sort warehouses based on item quantity in descending manner
This commit is contained in:
commit
5f2463933a
@ -497,24 +497,18 @@ def warehouse_query(doctype, txt, searchfield, start, page_len, filters):
|
|||||||
conditions, bin_conditions = [], []
|
conditions, bin_conditions = [], []
|
||||||
filter_dict = get_doctype_wise_filters(filters)
|
filter_dict = get_doctype_wise_filters(filters)
|
||||||
|
|
||||||
sub_query = """ select round(`tabBin`.actual_qty, 2) from `tabBin`
|
|
||||||
where `tabBin`.warehouse = `tabWarehouse`.name
|
|
||||||
{bin_conditions} """.format(
|
|
||||||
bin_conditions=get_filters_cond(doctype, filter_dict.get("Bin"),
|
|
||||||
bin_conditions, ignore_permissions=True))
|
|
||||||
|
|
||||||
query = """select `tabWarehouse`.name,
|
query = """select `tabWarehouse`.name,
|
||||||
CONCAT_WS(" : ", "Actual Qty", ifnull( ({sub_query}), 0) ) as actual_qty
|
CONCAT_WS(" : ", "Actual Qty", ifnull(round(`tabBin`.actual_qty, 2), 0 )) actual_qty
|
||||||
from `tabWarehouse`
|
from `tabWarehouse` left join `tabBin`
|
||||||
|
on `tabBin`.warehouse = `tabWarehouse`.name {bin_conditions}
|
||||||
where
|
where
|
||||||
`tabWarehouse`.`{key}` like {txt}
|
`tabWarehouse`.`{key}` like {txt}
|
||||||
{fcond} {mcond}
|
{fcond} {mcond}
|
||||||
order by
|
order by ifnull(`tabBin`.actual_qty, 0) desc
|
||||||
`tabWarehouse`.name desc
|
|
||||||
limit
|
limit
|
||||||
{start}, {page_len}
|
{start}, {page_len}
|
||||||
""".format(
|
""".format(
|
||||||
sub_query=sub_query,
|
bin_conditions=get_filters_cond(doctype, filter_dict.get("Bin"),bin_conditions, ignore_permissions=True),
|
||||||
key=searchfield,
|
key=searchfield,
|
||||||
fcond=get_filters_cond(doctype, filter_dict.get("Warehouse"), conditions),
|
fcond=get_filters_cond(doctype, filter_dict.get("Warehouse"), conditions),
|
||||||
mcond=get_match_cond(doctype),
|
mcond=get_match_cond(doctype),
|
||||||
|
Loading…
Reference in New Issue
Block a user