Fixes in stock projected qty report

This commit is contained in:
Nabin Hait 2013-12-20 12:18:37 +05:30
parent 2a9e4e9a32
commit a888e29b0a
3 changed files with 9 additions and 13 deletions

View File

@ -3,7 +3,6 @@
from __future__ import unicode_literals
import webnotes
from webnotes import _
def execute(filters=None):
columns = get_columns()
@ -33,13 +32,6 @@ def get_columns():
"Batch:Link/Batch:100", "Serial #:Link/Serial No:100", "Company:Link/Company:100"]
def get_stock_ledger_entries(filters):
if not filters.get("company"):
webnotes.throw(_("Company is mandatory"))
if not filters.get("from_date"):
webnotes.throw(_("From Date is mandatory"))
if not filters.get("to_date"):
webnotes.throw(_("To Date is mandatory"))
return webnotes.conn.sql("""select concat_ws(" ", posting_date, posting_time) as date,
item_code, warehouse, actual_qty, qty_after_transaction,
stock_value, voucher_type, voucher_no, batch_no, serial_no, company

View File

@ -7,9 +7,7 @@ wn.query_reports["Stock Projected Qty"] = {
"fieldname":"company",
"label": wn._("Company"),
"fieldtype": "Link",
"options": "Company",
"default": wn.defaults.get_user_default("company"),
"reqd": 1
"options": "Company"
},
{
"fieldname":"warehouse",

View File

@ -13,7 +13,7 @@ def execute(filters=None):
projected_qty, item.re_order_level, item.re_order_qty
from `tabBin` bin,
(select name, company from tabWarehouse
where company=%(company)s {warehouse_conditions}) wh,
{warehouse_conditions}) wh,
(select name, item_name, description, stock_uom, item_group,
brand, re_order_level, re_order_qty
from `tabItem` {item_conditions}) item
@ -41,4 +41,10 @@ def get_item_conditions(filters):
return "where {}".format(" and ".join(conditions)) if conditions else ""
def get_warehouse_conditions(filters):
return " and name=%(warehouse)s" if filters.get("warehouse") else ""
conditions = []
if filters.get("company"):
conditions.append("company=%(company)s")
if filters.get("warehouse"):
conditions.append("name=%(warehouse)s")
return "where {}".format(" and ".join(conditions)) if conditions else ""