Merge pull request #21127 from marination/pos-display-stock-item-develop
fix(pos): fix pos not display only in-stock item
This commit is contained in:
commit
28bad8749c
@ -64,29 +64,39 @@ def get_items(start, page_length, price_list, item_group, search_value="", pos_p
|
|||||||
for d in item_prices_data:
|
for d in item_prices_data:
|
||||||
item_prices[d.item_code] = d
|
item_prices[d.item_code] = d
|
||||||
|
|
||||||
|
# prepare filter for bin query
|
||||||
if display_items_in_stock:
|
bin_filters = {'item_code': ['in', items]}
|
||||||
filters = {'actual_qty': [">", 0], 'item_code': ['in', items]}
|
|
||||||
|
|
||||||
if warehouse:
|
if warehouse:
|
||||||
filters['warehouse'] = warehouse
|
bin_filters['warehouse'] = warehouse
|
||||||
|
if display_items_in_stock:
|
||||||
|
bin_filters['actual_qty'] = [">", 0]
|
||||||
|
|
||||||
bin_data = frappe._dict(
|
# query item bin
|
||||||
frappe.get_all("Bin", fields = ["item_code", "sum(actual_qty) as actual_qty"],
|
bin_data = frappe.get_all(
|
||||||
filters = filters, group_by = "item_code")
|
'Bin', fields=['item_code', 'sum(actual_qty) as actual_qty'],
|
||||||
|
filters=bin_filters, group_by='item_code'
|
||||||
)
|
)
|
||||||
|
|
||||||
for item in items_data:
|
# convert list of dict into dict as {item_code: actual_qty}
|
||||||
row = {}
|
bin_dict = {}
|
||||||
|
for b in bin_data:
|
||||||
|
bin_dict[b.get('item_code')] = b.get('actual_qty')
|
||||||
|
|
||||||
|
for item in items_data:
|
||||||
|
item_code = item.item_code
|
||||||
|
item_price = item_prices.get(item_code) or {}
|
||||||
|
item_stock_qty = bin_dict.get(item_code)
|
||||||
|
|
||||||
|
if display_items_in_stock and not item_stock_qty:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
row = {}
|
||||||
row.update(item)
|
row.update(item)
|
||||||
item_price = item_prices.get(item.item_code) or {}
|
|
||||||
row.update({
|
row.update({
|
||||||
'price_list_rate': item_price.get('price_list_rate'),
|
'price_list_rate': item_price.get('price_list_rate'),
|
||||||
'currency': item_price.get('currency'),
|
'currency': item_price.get('currency'),
|
||||||
'actual_qty': bin_data.get('actual_qty')
|
'actual_qty': item_stock_qty,
|
||||||
})
|
})
|
||||||
|
|
||||||
result.append(row)
|
result.append(row)
|
||||||
|
|
||||||
res = {
|
res = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user