fix: Sider and Patch tests

This commit is contained in:
marination 2021-06-02 13:24:06 +05:30
parent b0d7e32018
commit ea30ce4c51
4 changed files with 24 additions and 21 deletions

View File

@ -132,12 +132,14 @@ class ECommerceSettings(Document):
def on_change(self):
old_doc = self.get_doc_before_save()
old_fields = old_doc.search_index_fields
new_fields = self.search_index_fields
# if search index fields get changed
if not (new_fields == old_fields):
create_website_items_index()
if old_doc:
old_fields = old_doc.search_index_fields
new_fields = self.search_index_fields
# if search index fields get changed
if not (new_fields == old_fields):
create_website_items_index()
def validate_cart_settings(doc, method):
frappe.get_doc("E Commerce Settings", "E Commerce Settings").run_method("validate")

View File

@ -18,11 +18,11 @@ erpnext.ProductSearch = class {
bindSearchAction() {
let me = this;
this.searchBox.on("focus", (e) => {
this.searchBox.on("focus", () => {
this.search_dropdown.removeClass("hidden");
});
this.searchBox.on("focusout", (e) => {
this.searchBox.on("focusout", () => {
this.search_dropdown.addClass("hidden");
});
@ -53,7 +53,7 @@ erpnext.ProductSearch = class {
query: query
},
callback: (data) => {
me.populateCategoriesList(data)
me.populateCategoriesList(data);
}
});
}
@ -211,16 +211,16 @@ erpnext.ProductSearch = class {
return;
}
let html = ""
let search_results = data.message.results
let html = "";
let search_results = data.message.results;
search_results.forEach((category) => {
html += `
<div class="mb-2" style="font-weight: 400;">
<a href="/${category.route}">${category.name}</a>
</div>
`;
})
});
this.category_container.html(html);
}
}
};

View File

@ -120,7 +120,7 @@ def delete_item_from_index(website_item_doc):
try:
cache.delete(key)
except:
except Exception:
return False
delete_from_ac_dict(website_item_doc)
@ -152,7 +152,7 @@ def define_autocomplete_dictionary():
try:
cache.delete(make_key(WEBSITE_ITEM_NAME_AUTOCOMPLETE))
cache.delete(make_key(WEBSITE_ITEM_CATEGORY_AUTOCOMPLETE))
except:
except Exception:
return False
items = frappe.get_all(

View File

@ -70,13 +70,14 @@ def get_category_records(categories):
if frappe.get_meta(doctype, cached=True).get_field("image"):
fields += ["image"]
categorical_data[category] = frappe.db.sql(f"""
Select
{",".join(fields)}
from
`tab{doctype}`""",
as_dict=1
)
categorical_data[category] = frappe.db.sql(
f"""
Select
{",".join(fields)}
from
`tab{doctype}`
""",
as_dict=1)
return categorical_data