Skip to content

Commit

Permalink
fix: inventory dimension filter not overriding with existing filter f…
Browse files Browse the repository at this point in the history
…or stock ledger report

(cherry picked from commit 0e388ba)
  • Loading branch information
rohitwaghchaure authored and mergify[bot] committed Feb 20, 2023
1 parent 7556739 commit 6959283
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions erpnext/public/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,9 @@ $.extend(erpnext.utils, {
callback: function(r) {
if (r.message && r.message.length) {
r.message.forEach((dimension) => {
let found = filters.some(el => el.fieldname === dimension['fieldname']);
let existing_filter = filters.filter(el => el.fieldname === dimension['fieldname']);

if (!found) {
if (!existing_filter.length) {
filters.splice(index, 0, {
"fieldname": dimension["fieldname"],
"label": __(dimension["doctype"]),
Expand All @@ -232,6 +232,11 @@ $.extend(erpnext.utils, {
return frappe.db.get_link_options(dimension["doctype"], txt);
},
});
} else {
existing_filter[0]['fieldtype'] = "MultiSelectList";
existing_filter[0]['get_data'] = function(txt) {
return frappe.db.get_link_options(dimension["doctype"], txt);
}
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion erpnext/stock/report/stock_ledger/stock_ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ def get_stock_ledger_entries(filters, items):
query = query.where(sle.item_code.isin(items))

for field in ["voucher_no", "batch_no", "project", "company"]:
if filters.get(field):
if filters.get(field) and field not in inventory_dimension_fields:
query = query.where(sle[field] == filters.get(field))

query = apply_warehouse_filter(query, sle, filters)
Expand Down

0 comments on commit 6959283

Please sign in to comment.