fix: select multiple values for accounting dimenssion
This commit is contained in:
parent
ead08aa192
commit
69be22ba7c
@ -234,17 +234,19 @@ def get_checks_for_pl_and_bs_accounts():
|
|||||||
return dimensions
|
return dimensions
|
||||||
|
|
||||||
|
|
||||||
def get_dimension_with_children(doctype, dimension):
|
def get_dimension_with_children(doctype, dimensions):
|
||||||
|
|
||||||
if isinstance(dimension, list):
|
if isinstance(dimensions, str):
|
||||||
dimension = dimension[0]
|
dimensions = [dimensions]
|
||||||
|
|
||||||
all_dimensions = []
|
all_dimensions = []
|
||||||
lft, rgt = frappe.db.get_value(doctype, dimension, ["lft", "rgt"])
|
|
||||||
children = frappe.get_all(
|
for dimension in dimensions:
|
||||||
doctype, filters={"lft": [">=", lft], "rgt": ["<=", rgt]}, order_by="lft"
|
lft, rgt = frappe.db.get_value(doctype, dimension, ["lft", "rgt"])
|
||||||
)
|
children = frappe.get_all(
|
||||||
all_dimensions += [c.name for c in children]
|
doctype, filters={"lft": [">=", lft], "rgt": ["<=", rgt]}, order_by="lft"
|
||||||
|
)
|
||||||
|
all_dimensions += [c.name for c in children]
|
||||||
|
|
||||||
return all_dimensions
|
return all_dimensions
|
||||||
|
|
||||||
|
@ -507,7 +507,7 @@ def get_additional_conditions(from_date, ignore_closing_entries, filters):
|
|||||||
)
|
)
|
||||||
additional_conditions.append("{0} in %({0})s".format(dimension.fieldname))
|
additional_conditions.append("{0} in %({0})s".format(dimension.fieldname))
|
||||||
else:
|
else:
|
||||||
additional_conditions.append("{0} in (%({0})s)".format(dimension.fieldname))
|
additional_conditions.append("{0} in %({0})s".format(dimension.fieldname))
|
||||||
|
|
||||||
return " and {}".format(" and ".join(additional_conditions)) if additional_conditions else ""
|
return " and {}".format(" and ".join(additional_conditions)) if additional_conditions else ""
|
||||||
|
|
||||||
|
@ -275,7 +275,7 @@ def get_conditions(filters):
|
|||||||
)
|
)
|
||||||
conditions.append("{0} in %({0})s".format(dimension.fieldname))
|
conditions.append("{0} in %({0})s".format(dimension.fieldname))
|
||||||
else:
|
else:
|
||||||
conditions.append("{0} in (%({0})s)".format(dimension.fieldname))
|
conditions.append("{0} in %({0})s".format(dimension.fieldname))
|
||||||
|
|
||||||
return "and {}".format(" and ".join(conditions)) if conditions else ""
|
return "and {}".format(" and ".join(conditions)) if conditions else ""
|
||||||
|
|
||||||
|
@ -237,7 +237,7 @@ def get_conditions(filters):
|
|||||||
else:
|
else:
|
||||||
conditions += (
|
conditions += (
|
||||||
common_condition
|
common_condition
|
||||||
+ "and ifnull(`tabPurchase Invoice Item`.{0}, '') in (%({0})s))".format(dimension.fieldname)
|
+ "and ifnull(`tabPurchase Invoice Item`.{0}, '') in %({0})s)".format(dimension.fieldname)
|
||||||
)
|
)
|
||||||
|
|
||||||
return conditions
|
return conditions
|
||||||
|
@ -405,7 +405,7 @@ def get_conditions(filters):
|
|||||||
else:
|
else:
|
||||||
conditions += (
|
conditions += (
|
||||||
common_condition
|
common_condition
|
||||||
+ "and ifnull(`tabSales Invoice Item`.{0}, '') in (%({0})s))".format(dimension.fieldname)
|
+ "and ifnull(`tabSales Invoice Item`.{0}, '') in %({0})s)".format(dimension.fieldname)
|
||||||
)
|
)
|
||||||
|
|
||||||
return conditions
|
return conditions
|
||||||
|
@ -188,9 +188,9 @@ def get_rootwise_opening_balances(filters, report_type):
|
|||||||
filters[dimension.fieldname] = get_dimension_with_children(
|
filters[dimension.fieldname] = get_dimension_with_children(
|
||||||
dimension.document_type, filters.get(dimension.fieldname)
|
dimension.document_type, filters.get(dimension.fieldname)
|
||||||
)
|
)
|
||||||
additional_conditions += "and {0} in %({0})s".format(dimension.fieldname)
|
additional_conditions += " and {0} in %({0})s".format(dimension.fieldname)
|
||||||
else:
|
else:
|
||||||
additional_conditions += "and {0} in (%({0})s)".format(dimension.fieldname)
|
additional_conditions += " and {0} in %({0})s".format(dimension.fieldname)
|
||||||
|
|
||||||
query_filters.update({dimension.fieldname: filters.get(dimension.fieldname)})
|
query_filters.update({dimension.fieldname: filters.get(dimension.fieldname)})
|
||||||
|
|
||||||
|
@ -213,8 +213,10 @@ $.extend(erpnext.utils, {
|
|||||||
filters.splice(index, 0, {
|
filters.splice(index, 0, {
|
||||||
"fieldname": dimension["fieldname"],
|
"fieldname": dimension["fieldname"],
|
||||||
"label": __(dimension["label"]),
|
"label": __(dimension["label"]),
|
||||||
"fieldtype": "Link",
|
"fieldtype": "MultiSelectList",
|
||||||
"options": dimension["document_type"]
|
get_data: function(txt) {
|
||||||
|
return frappe.db.get_link_options(dimension["document_type"], txt);
|
||||||
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user