Merge branch 'shopping-cart' of https://github.com/frappe/erpnext into rebrand-ui

This commit is contained in:
prssanna
2021-01-21 13:04:58 +05:30
50 changed files with 2444 additions and 413 deletions

View File

@@ -61,6 +61,19 @@ frappe.ui.form.on("Item Group", {
frappe.set_route("List", "Item", {"item_group": frm.doc.name});
});
}
frappe.model.with_doctype('Item', () => {
const item_meta = frappe.get_meta('Item');
const valid_fields = item_meta.fields.filter(
df => ['Link', 'Table MultiSelect'].includes(df.fieldtype) && !df.hidden
).map(df => ({ label: df.label, value: df.fieldname }));
const field = frappe.meta.get_docfield("Website Filter Field", "fieldname", frm.docname);
field.fieldtype = 'Select';
field.options = valid_fields;
frm.fields_dict.filter_fields.grid.refresh();
});
},
set_root_readonly: function(frm) {

View File

@@ -24,8 +24,12 @@
"route",
"weightage",
"slideshow",
"website_title",
"description",
"website_specifications",
"website_filters_section",
"filter_fields",
"filter_attributes",
"lft",
"rgt",
"old_parent"
@@ -180,6 +184,28 @@
"options": "Item Group",
"print_hide": 1,
"report_hide": 1
},
{
"fieldname": "website_filters_section",
"fieldtype": "Section Break",
"label": "Website Filters"
},
{
"fieldname": "filter_fields",
"fieldtype": "Table",
"label": "Item Fields",
"options": "Website Filter Field"
},
{
"fieldname": "filter_attributes",
"fieldtype": "Table",
"label": "Attributes",
"options": "Website Attribute"
},
{
"fieldname": "website_title",
"fieldtype": "Data",
"label": "Title"
}
],
"icon": "fa fa-sitemap",
@@ -188,7 +214,7 @@
"is_tree": 1,
"links": [],
"max_attachments": 3,
"modified": "2020-03-18 18:10:34.383363",
"modified": "2020-12-30 12:57:38.876956",
"modified_by": "Administrator",
"module": "Setup",
"name": "Item Group",

View File

@@ -13,13 +13,16 @@ from frappe.website.doctype.website_slideshow.website_slideshow import get_slide
from erpnext.shopping_cart.product_info import set_product_info_for_website
from erpnext.utilities.product import get_qty_in_stock
from six.moves.urllib.parse import quote
from erpnext.shopping_cart.product_query import ProductQuery
from erpnext.shopping_cart.filters import ProductFiltersBuilder
class ItemGroup(NestedSet, WebsiteGenerator):
nsm_parent_field = 'parent_item_group'
website = frappe._dict(
condition_field = "show_in_website",
template = "templates/generators/item_group.html",
no_cache = 1
no_cache = 1,
no_breadcrumbs = 1
)
def autoname(self):
@@ -70,18 +73,58 @@ class ItemGroup(NestedSet, WebsiteGenerator):
context.page_length = cint(frappe.db.get_single_value('Products Settings', 'products_per_page')) or 6
context.search_link = '/product_search'
start = int(frappe.form_dict.start or 0)
if start < 0:
if frappe.form_dict:
search = frappe.form_dict.search
field_filters = frappe.parse_json(frappe.form_dict.field_filters)
attribute_filters = frappe.parse_json(frappe.form_dict.attribute_filters)
start = frappe.parse_json(frappe.form_dict.start)
else:
search = None
attribute_filters = None
field_filters = {}
start = 0
if not field_filters:
field_filters = {}
# Ensure the query remains within current item group
field_filters['item_group'] = self.name
engine = ProductQuery()
context.items = engine.query(attribute_filters, field_filters, search, start)
filter_engine = ProductFiltersBuilder(self.name)
context.field_filters = filter_engine.get_field_filters()
context.attribute_filters = filter_engine.get_attribute_fitlers()
context.update({
"items": get_product_list_for_group(product_group = self.name, start=start,
limit=context.page_length + 1, search=frappe.form_dict.get("search")),
"parents": get_parent_item_groups(self.parent_item_group),
"title": self.name
})
if self.slideshow:
context.update(get_slideshow(self))
values = {
'show_indicators': 1,
'show_controls': 0,
'rounded': 1,
'slider_name': self.slideshow
}
slideshow = frappe.get_doc("Website Slideshow", self.slideshow)
slides = slideshow.get({"doctype":"Website Slideshow Item"})
for index, slide in enumerate(slides):
values[f"slide_{index + 1}_image"] = slide.image
values[f"slide_{index + 1}_title"] = slide.heading
values[f"slide_{index + 1}_subtitle"] = slide.description
values[f"slide_{index + 1}_theme"] = slide.theme or "Light"
values[f"slide_{index + 1}_content_align"] = slide.content_align or "Centre"
values[f"slide_{index + 1}_primary_action_label"] = slide.label
values[f"slide_{index + 1}_primary_action"] = slide.url
context.slideshow = values
context.breadcrumbs = 0
context.title = self.website_title or self.name
return context