Merge pull request #21516 from marination/stock-balance-cleanup
chore: Added company filter and minor cleanup in Stock Balance Report
This commit is contained in:
commit
268df35d80
@ -3,6 +3,14 @@
|
||||
|
||||
frappe.query_reports["Stock Balance"] = {
|
||||
"filters": [
|
||||
{
|
||||
"fieldname": "company",
|
||||
"label": __("Company"),
|
||||
"fieldtype": "Link",
|
||||
"width": "80",
|
||||
"options": "Company",
|
||||
"default": frappe.defaults.get_default("company")
|
||||
},
|
||||
{
|
||||
"fieldname":"from_date",
|
||||
"label": __("From Date"),
|
||||
@ -26,12 +34,6 @@ frappe.query_reports["Stock Balance"] = {
|
||||
"width": "80",
|
||||
"options": "Item Group"
|
||||
},
|
||||
{
|
||||
"fieldname":"brand",
|
||||
"label": __("Brand"),
|
||||
"fieldtype": "Link",
|
||||
"options": "Brand"
|
||||
},
|
||||
{
|
||||
"fieldname": "item_code",
|
||||
"label": __("Item"),
|
||||
@ -84,5 +86,18 @@ frappe.query_reports["Stock Balance"] = {
|
||||
"label": __('Show Stock Ageing Data'),
|
||||
"fieldtype": 'Check'
|
||||
},
|
||||
]
|
||||
],
|
||||
|
||||
"formatter": function (value, row, column, data, default_formatter) {
|
||||
value = default_formatter(value, row, column, data);
|
||||
|
||||
if (column.fieldname == "out_qty" && data && data.out_qty > 0) {
|
||||
value = "<span style='color:red'>" + value + "</span>";
|
||||
}
|
||||
else if (column.fieldname == "in_qty" && data && data.in_qty > 0) {
|
||||
value = "<span style='color:green'>" + value + "</span>";
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
};
|
||||
|
@ -1,17 +1,19 @@
|
||||
{
|
||||
"add_total_row": 1,
|
||||
"creation": "2014-10-10 17:58:11.577901",
|
||||
"disable_prepared_report": 0,
|
||||
"disabled": 0,
|
||||
"docstatus": 0,
|
||||
"doctype": "Report",
|
||||
"idx": 2,
|
||||
"is_standard": "Yes",
|
||||
"modified": "2018-08-14 15:24:41.395557",
|
||||
"modified": "2020-04-30 13:46:14.680354",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Stock",
|
||||
"name": "Stock Balance",
|
||||
"owner": "Administrator",
|
||||
"prepared_report": 1,
|
||||
"query": "",
|
||||
"ref_doctype": "Stock Ledger Entry",
|
||||
"report_name": "Stock Balance",
|
||||
"report_type": "Script Report",
|
||||
|
@ -94,8 +94,6 @@ def get_columns(filters):
|
||||
{"label": _("Item"), "fieldname": "item_code", "fieldtype": "Link", "options": "Item", "width": 100},
|
||||
{"label": _("Item Name"), "fieldname": "item_name", "width": 150},
|
||||
{"label": _("Item Group"), "fieldname": "item_group", "fieldtype": "Link", "options": "Item Group", "width": 100},
|
||||
{"label": _("Brand"), "fieldname": "brand", "fieldtype": "Link", "options": "Brand", "width": 90},
|
||||
{"label": _("Description"), "fieldname": "description", "width": 140},
|
||||
{"label": _("Warehouse"), "fieldname": "warehouse", "fieldtype": "Link", "options": "Warehouse", "width": 100},
|
||||
{"label": _("Stock UOM"), "fieldname": "stock_uom", "fieldtype": "Link", "options": "UOM", "width": 90},
|
||||
{"label": _("Balance Qty"), "fieldname": "bal_qty", "fieldtype": "Float", "width": 100, "convertible": "qty"},
|
||||
@ -132,6 +130,9 @@ def get_conditions(filters):
|
||||
else:
|
||||
frappe.throw(_("'To Date' is required"))
|
||||
|
||||
if filters.get("company"):
|
||||
conditions += " and sle.company = %s" % frappe.db.escape(filters.get("company"))
|
||||
|
||||
if filters.get("warehouse"):
|
||||
warehouse_details = frappe.db.get_value("Warehouse",
|
||||
filters.get("warehouse"), ["lft", "rgt"], as_dict=1)
|
||||
@ -233,8 +234,6 @@ def get_items(filters):
|
||||
if filters.get("item_code"):
|
||||
conditions.append("item.name=%(item_code)s")
|
||||
else:
|
||||
if filters.get("brand"):
|
||||
conditions.append("item.brand=%(brand)s")
|
||||
if filters.get("item_group"):
|
||||
conditions.append(get_item_group_condition(filters.get("item_group")))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user