How to add new column to stock balance and populate data from bin Doctype

Hello @komsel2228 i have been working on adding new column to stock balance report i’m having trouble populating the bin data to the newly added bin column can anyone help me on what i might be doing wrong.
Your help will be much appreciated.
Screenshot of output


added new function to my stock_balance.py code

def get_bin_list(filters):
	conditions = []
	
	if filters.item_code:
		conditions.append("item_code = '%s' "%filters.item_code)
		
	if filters.warehouse:
		warehouse_details = frappe.db.get_value("Warehouse", filters.warehouse, ["lft", "rgt"], as_dict=1)

		if warehouse_details:
			conditions.append(" exists (select name from `tabWarehouse` wh \
				where wh.lft >= %s and wh.rgt <= %s and bin.warehouse = wh.name)"%(warehouse_details.lft,
				warehouse_details.rgt))

	bin_list = frappe.db.sql("""select item_code, warehouse,bin_label
		from tabBin bin {conditions} order by item_code, warehouse
		""".format(conditions=" where " + " and ".join(conditions) if conditions else ""), as_dict=1)

	return bin_list

Menu > add columns.
Select the column you wish to add.
It will be done easily.

Thanks for the reply @winter_wolf, i’m sorry where can this Menu > add columns be found?
I’m using
erpnext 10.1.31
frappe 10.1.30

you have to merge bin_list dict into Data List before you return data to report.

Thanks for the reply @adnan , how can i go about doing that i have been trying with very little success. check my code below

tbin_map = get_bin_list(filters)
	#frappe.throw(tbin_map)

	data = []
	for (company, item, warehouse) in sorted(iwb_map):
		qty_dict = iwb_map[(company, item, warehouse)]
		item_reorder_level = 0
		item_reorder_qty = 0
		if item + warehouse in item_reorder_detail_map:
			item_reorder_level = item_reorder_detail_map[item + warehouse]["warehouse_reorder_level"]
			item_reorder_qty = item_reorder_detail_map[item + warehouse]["warehouse_reorder_qty"]

		report_data = [item, item_map[item]["item_name"],
			item_map[item]["item_group"],
			item_map[item]["brand"],
			item_map[item]["description"], warehouse,
			item_map[item]["stock_uom"], qty_dict.opening_qty,
			qty_dict.opening_val, qty_dict.in_qty,
			qty_dict.in_val, qty_dict.out_qty,
			qty_dict.out_val, qty_dict.bal_qty,
			qty_dict.bal_val, qty_dict.val_rate,
			item_reorder_level,
			item_reorder_qty,
			company,
		]

		if filters.get('show_variant_attributes', 0) == 1:
			variants_attributes = get_variants_attributes()
			report_data += [item_map[item].get(i) for i in variants_attributes]
		b_map = {}
		for n in tbin_map:		
			key = (n.bin_label, n.item_code, n.warehouse)
			b_map[key] = frappe._dict({})
			bn_dict = b_map[(n.bin_label, n.item_code, n.warehouse)]
			report_data += bn_dict["bin_label"]
		
		data.append(report_data)

The error screenshot
bin_error

This feature is available on v12.

Thanks @winter_wolf let me keep on trying to see if i can find a way

The following changes to the for loop adding the dict to the data solved the issue. Thanks to everyone who took their time to respond to this issue.

for bn in tbin_map:
		for d in data:
			if bn["item_code"] and bn["warehouse"] in d:
				d.append(bn["bin_label"])