fix: Filters did not consider Website Item Group
This commit is contained in:
parent
d802d73973
commit
1b9b72d12e
@ -22,12 +22,15 @@ class ProductFiltersBuilder:
|
||||
|
||||
filter_data = []
|
||||
for df in fields:
|
||||
filters = {}
|
||||
filters, or_filters = {}, []
|
||||
if df.fieldtype == "Link":
|
||||
if self.item_group:
|
||||
filters['item_group'] = self.item_group
|
||||
or_filters.extend([
|
||||
["item_group", "=", self.item_group],
|
||||
["Website Item Group", "item_group", "=", self.item_group]
|
||||
])
|
||||
|
||||
values = frappe.get_all("Item", fields=[df.fieldname], filters=filters, distinct="True", pluck=df.fieldname)
|
||||
values = frappe.get_all("Item", fields=[df.fieldname], filters=filters, or_filters=or_filters, distinct="True", pluck=df.fieldname, debug=1)
|
||||
else:
|
||||
doctype = df.get_link_doctype()
|
||||
|
||||
@ -44,7 +47,9 @@ class ProductFiltersBuilder:
|
||||
values = [d.name for d in frappe.get_all(doctype, filters)]
|
||||
|
||||
# Remove None
|
||||
values = values.remove(None) if None in values else values
|
||||
if None in values:
|
||||
values.remove(None)
|
||||
|
||||
if values:
|
||||
filter_data.append([df, values])
|
||||
|
||||
@ -61,14 +66,18 @@ class ProductFiltersBuilder:
|
||||
for attr_doc in attribute_docs:
|
||||
selected_attributes = []
|
||||
for attr in attr_doc.item_attribute_values:
|
||||
or_filters = []
|
||||
filters= [
|
||||
["Item Variant Attribute", "attribute", "=", attr.parent],
|
||||
["Item Variant Attribute", "attribute_value", "=", attr.attribute_value]
|
||||
]
|
||||
if self.item_group:
|
||||
filters.append(["item_group", "=", self.item_group])
|
||||
or_filters.extend([
|
||||
["item_group", "=", self.item_group],
|
||||
["Website Item Group", "item_group", "=", self.item_group]
|
||||
])
|
||||
|
||||
if frappe.db.get_all("Item", filters, limit=1):
|
||||
if frappe.db.get_all("Item", filters, or_filters=or_filters, limit=1):
|
||||
selected_attributes.append(attr)
|
||||
|
||||
if selected_attributes:
|
||||
|
@ -101,7 +101,7 @@ class ProductQuery:
|
||||
for item in result:
|
||||
product_info = get_product_info_for_website(item.item_code, skip_quotation_creation=True).get('product_info')
|
||||
if product_info:
|
||||
item.formatted_price = product_info.get('price', {}).get('formatted_price')
|
||||
item.formatted_price = (product_info.get('price') or {}).get('formatted_price')
|
||||
|
||||
return result
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user