Merge pull request #37055 from deepeshgarg007/dimension_filters_gl

fix: Apply dimension filter, irrespective of dimension columns
This commit is contained in:
Deepesh Garg 2023-09-13 10:05:58 +05:30 committed by GitHub
commit 88f7e57edf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -279,20 +279,19 @@ def get_conditions(filters):
if match_conditions:
conditions.append(match_conditions)
if filters.get("include_dimensions"):
accounting_dimensions = get_accounting_dimensions(as_list=False)
accounting_dimensions = get_accounting_dimensions(as_list=False)
if accounting_dimensions:
for dimension in accounting_dimensions:
if not dimension.disabled:
if filters.get(dimension.fieldname):
if frappe.get_cached_value("DocType", dimension.document_type, "is_tree"):
filters[dimension.fieldname] = get_dimension_with_children(
dimension.document_type, filters.get(dimension.fieldname)
)
conditions.append("{0} in %({0})s".format(dimension.fieldname))
else:
conditions.append("{0} in %({0})s".format(dimension.fieldname))
if accounting_dimensions:
for dimension in accounting_dimensions:
if not dimension.disabled:
if filters.get(dimension.fieldname):
if frappe.get_cached_value("DocType", dimension.document_type, "is_tree"):
filters[dimension.fieldname] = get_dimension_with_children(
dimension.document_type, filters.get(dimension.fieldname)
)
conditions.append("{0} in %({0})s".format(dimension.fieldname))
else:
conditions.append("{0} in %({0})s".format(dimension.fieldname))
return "and {}".format(" and ".join(conditions)) if conditions else ""