Merge pull request #21516 from marination/stock-balance-cleanup
chore: Added company filter and minor cleanup in Stock Balance Report
diff --git a/erpnext/stock/report/stock_balance/stock_balance.js b/erpnext/stock/report/stock_balance/stock_balance.js
index 537fa7c..7d22823 100644
--- a/erpnext/stock/report/stock_balance/stock_balance.js
+++ b/erpnext/stock/report/stock_balance/stock_balance.js
@@ -4,6 +4,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"),
"fieldtype": "Date",
@@ -27,12 +35,6 @@
"options": "Item Group"
},
{
- "fieldname":"brand",
- "label": __("Brand"),
- "fieldtype": "Link",
- "options": "Brand"
- },
- {
"fieldname": "item_code",
"label": __("Item"),
"fieldtype": "Link",
@@ -84,5 +86,18 @@
"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;
+ }
};
diff --git a/erpnext/stock/report/stock_balance/stock_balance.json b/erpnext/stock/report/stock_balance/stock_balance.json
index 2f20b20..8c45f0c 100644
--- a/erpnext/stock/report/stock_balance/stock_balance.json
+++ b/erpnext/stock/report/stock_balance/stock_balance.json
@@ -1,24 +1,26 @@
{
- "add_total_row": 1,
- "creation": "2014-10-10 17:58:11.577901",
- "disabled": 0,
- "docstatus": 0,
- "doctype": "Report",
- "idx": 2,
- "is_standard": "Yes",
- "modified": "2018-08-14 15:24:41.395557",
- "modified_by": "Administrator",
- "module": "Stock",
- "name": "Stock Balance",
- "owner": "Administrator",
- "prepared_report": 1,
- "ref_doctype": "Stock Ledger Entry",
- "report_name": "Stock Balance",
- "report_type": "Script Report",
+ "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": "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",
"roles": [
{
"role": "Stock User"
- },
+ },
{
"role": "Accounts Manager"
}
diff --git a/erpnext/stock/report/stock_balance/stock_balance.py b/erpnext/stock/report/stock_balance/stock_balance.py
index ab87ee1..74a4f6e 100644
--- a/erpnext/stock/report/stock_balance/stock_balance.py
+++ b/erpnext/stock/report/stock_balance/stock_balance.py
@@ -94,8 +94,6 @@
{"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 @@
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 @@
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")))