From 9b50b0a7623f3de2d02aed12f6e0d98e749cf50b Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 29 Sep 2014 10:48:45 +0530 Subject: [PATCH 1/3] Fixes for item list view --- erpnext/stock/doctype/item/item_list.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/erpnext/stock/doctype/item/item_list.js b/erpnext/stock/doctype/item/item_list.js index 330faedf62..e1cd020b5f 100644 --- a/erpnext/stock/doctype/item/item_list.js +++ b/erpnext/stock/doctype/item/item_list.js @@ -1,5 +1,5 @@ frappe.listview_settings['Item'] = { - add_fields: ["item_name", "stock_uom", "item_group", "image", - "is_stock_item", "is_sales_item", "is_purchase_item", - "is_manufactured_item", "show_in_website"] + add_fields: ["`tabItem`.`item_name`", "`tabItem`.`stock_uom`", "`tabItem`.`item_group`", "`tabItem`.`image`", + "`tabItem`.`is_stock_item`", "`tabItem`.`is_sales_item`", "`tabItem`.`is_purchase_item`", + "`tabItem`.`is_manufactured_item`", "`tabItem`.`show_in_website`"] }; From d60235e2397c9d0885342dee5d683213827f48f4 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 29 Sep 2014 11:35:52 +0530 Subject: [PATCH 2/3] minor fix in warehouse-wise stock balance report --- .../warehouse_wise_stock_balance.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/erpnext/stock/report/warehouse_wise_stock_balance/warehouse_wise_stock_balance.py b/erpnext/stock/report/warehouse_wise_stock_balance/warehouse_wise_stock_balance.py index 775f6f11bb..dc552cb773 100644 --- a/erpnext/stock/report/warehouse_wise_stock_balance/warehouse_wise_stock_balance.py +++ b/erpnext/stock/report/warehouse_wise_stock_balance/warehouse_wise_stock_balance.py @@ -71,10 +71,10 @@ def get_item_warehouse_map(filters): for d in sle: iwb_map.setdefault(d.company, {}).setdefault(d.item_code, {}).\ setdefault(d.warehouse, frappe._dict({\ - "opening_qty": 0.0, "opening_val": 0.0, - "in_qty": 0.0, "in_val": 0.0, - "out_qty": 0.0, "out_val": 0.0, - "bal_qty": 0.0, "bal_val": 0.0, + "opening_qty": 0.0, "opening_val": 0.0, + "in_qty": 0.0, "in_val": 0.0, + "out_qty": 0.0, "out_val": 0.0, + "bal_qty": 0.0, "bal_val": 0.0, "val_rate": 0.0, "uom": None })) qty_dict = iwb_map[d.company][d.item_code][d.warehouse] @@ -82,19 +82,19 @@ def get_item_warehouse_map(filters): if d.posting_date < filters["from_date"]: qty_dict.opening_qty += flt(d.actual_qty) - qty_dict.opening_val += flt(d.actual_qty * d.valuation_rate) + qty_dict.opening_val += flt(d.actual_qty) * flt(d.valuation_rate) elif d.posting_date >= filters["from_date"] and d.posting_date <= filters["to_date"]: qty_dict.val_rate = d.valuation_rate if flt(d.actual_qty) > 0: qty_dict.in_qty += flt(d.actual_qty) - qty_dict.in_val += flt(d.actual_qty * d.valuation_rate) + qty_dict.in_val += flt(d.actual_qty) * flt(d.valuation_rate) else: qty_dict.out_qty += abs(flt(d.actual_qty)) - qty_dict.out_val += flt(abs(flt(d.actual_qty)) * d.valuation_rate) + qty_dict.out_val += flt(abs(flt(d.actual_qty) * flt(d.valuation_rate))) qty_dict.bal_qty += flt(d.actual_qty) - qty_dict.bal_val += flt(d.actual_qty * d.valuation_rate) + qty_dict.bal_val += flt(d.actual_qty) * flt(d.valuation_rate) return iwb_map From 82d7c0c9eb8bdc75cf46907f393eadfad2d28641 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 29 Sep 2014 15:07:51 +0530 Subject: [PATCH 3/3] Patch: Fix gl entries for stock transactions --- .../fix_gl_entries_for_stock_transactions.py | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 erpnext/patches/v4_2/fix_gl_entries_for_stock_transactions.py diff --git a/erpnext/patches/v4_2/fix_gl_entries_for_stock_transactions.py b/erpnext/patches/v4_2/fix_gl_entries_for_stock_transactions.py new file mode 100644 index 0000000000..e065d2d42f --- /dev/null +++ b/erpnext/patches/v4_2/fix_gl_entries_for_stock_transactions.py @@ -0,0 +1,26 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import frappe + +def execute(): + warehouses_with_account = frappe.db.sql_list("""select master_name from tabAccount + where ifnull(account_type, '') = 'Warehouse'""") + + stock_vouchers_without_gle = frappe.db.sql("""select distinct sle.voucher_type, sle.voucher_no + from `tabStock Ledger Entry` sle + where sle.warehouse in (%s) + and not exists(select name from `tabGL Entry` + where voucher_type=sle.voucher_type and voucher_no=sle.voucher_no) + order by sle.posting_date""" % + ', '.join(['%s']*len(warehouses_with_account)), tuple(warehouses_with_account)) + + for voucher_type, voucher_no in stock_vouchers_without_gle: + print voucher_type, voucher_no + frappe.db.sql("""delete from `tabGL Entry` + where voucher_type=%s and voucher_no=%s""", (voucher_type, voucher_no)) + + voucher = frappe.get_doc(voucher_type, voucher_no) + voucher.make_gl_entries() + frappe.db.commit()