fix: Fixed error on stock balance report
This commit is contained in:
parent
a85f008f30
commit
9ea19b8fe1
@ -173,15 +173,15 @@ def get_item_warehouse_map(filters, sle):
|
|||||||
qty_dict.val_rate = d.valuation_rate
|
qty_dict.val_rate = d.valuation_rate
|
||||||
qty_dict.bal_qty += qty_diff
|
qty_dict.bal_qty += qty_diff
|
||||||
qty_dict.bal_val += value_diff
|
qty_dict.bal_val += value_diff
|
||||||
|
|
||||||
iwb_map = filter_items_with_no_transactions(iwb_map)
|
iwb_map = filter_items_with_no_transactions(iwb_map)
|
||||||
|
|
||||||
return iwb_map
|
return iwb_map
|
||||||
|
|
||||||
def filter_items_with_no_transactions(iwb_map):
|
def filter_items_with_no_transactions(iwb_map):
|
||||||
for (company, item, warehouse) in sorted(iwb_map):
|
for (company, item, warehouse) in sorted(iwb_map):
|
||||||
qty_dict = iwb_map[(company, item, warehouse)]
|
qty_dict = iwb_map[(company, item, warehouse)]
|
||||||
|
|
||||||
no_transactions = True
|
no_transactions = True
|
||||||
float_precision = cint(frappe.db.get_default("float_precision")) or 3
|
float_precision = cint(frappe.db.get_default("float_precision")) or 3
|
||||||
for key, val in iteritems(qty_dict):
|
for key, val in iteritems(qty_dict):
|
||||||
@ -189,7 +189,7 @@ def filter_items_with_no_transactions(iwb_map):
|
|||||||
qty_dict[key] = val
|
qty_dict[key] = val
|
||||||
if key != "val_rate" and val:
|
if key != "val_rate" and val:
|
||||||
no_transactions = False
|
no_transactions = False
|
||||||
|
|
||||||
if no_transactions:
|
if no_transactions:
|
||||||
iwb_map.pop((company, item, warehouse))
|
iwb_map.pop((company, item, warehouse))
|
||||||
|
|
||||||
@ -216,20 +216,28 @@ def get_item_details(items, sle, filters):
|
|||||||
if not items:
|
if not items:
|
||||||
items = list(set([d.item_code for d in sle]))
|
items = list(set([d.item_code for d in sle]))
|
||||||
|
|
||||||
if items:
|
if not items:
|
||||||
cf_field = cf_join = ""
|
return item_details
|
||||||
if filters.get("include_uom"):
|
|
||||||
cf_field = ", ucd.conversion_factor"
|
|
||||||
cf_join = "left join `tabUOM Conversion Detail` ucd on ucd.parent=item.name and ucd.uom=%(include_uom)s"
|
|
||||||
|
|
||||||
for item in frappe.db.sql("""
|
cf_field = cf_join = ""
|
||||||
select item.name, item.item_name, item.description, item.item_group, item.brand, item.stock_uom{cf_field}
|
if filters.get("include_uom"):
|
||||||
from `tabItem` item
|
cf_field = ", ucd.conversion_factor"
|
||||||
|
cf_join = "left join `tabUOM Conversion Detail` ucd on ucd.parent=item.name and ucd.uom='%s'" \
|
||||||
|
% frappe.db.escape(filters.get("include_uom"))
|
||||||
|
|
||||||
|
item_codes = ', '.join(['"' + frappe.db.escape(i, percent=False) + '"' for i in items])
|
||||||
|
res = frappe.db.sql("""
|
||||||
|
select
|
||||||
|
item.name, item.item_name, item.description, item.item_group, item.brand, item.stock_uom {cf_field}
|
||||||
|
from
|
||||||
|
`tabItem` item
|
||||||
{cf_join}
|
{cf_join}
|
||||||
where item.name in ({names}) and ifnull(item.disabled, 0) = 0
|
where
|
||||||
""".format(cf_field=cf_field, cf_join=cf_join, names=', '.join(['"' + frappe.db.escape(i, percent=False) + '"' for i in items])),
|
item.name in ({item_codes}) and ifnull(item.disabled, 0) = 0
|
||||||
{"include_uom": filters.get("include_uom")}, as_dict=1):
|
""".format(cf_field=cf_field, cf_join=cf_join, item_codes=item_codes), as_dict=1)
|
||||||
item_details.setdefault(item.name, item)
|
|
||||||
|
for item in res:
|
||||||
|
item_details.setdefault(item.name, item)
|
||||||
|
|
||||||
if filters.get('show_variant_attributes', 0) == 1:
|
if filters.get('show_variant_attributes', 0) == 1:
|
||||||
variant_values = get_variant_values_for(list(item_details))
|
variant_values = get_variant_values_for(list(item_details))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user