diff --git a/erpnext/controllers/item_variant.py b/erpnext/controllers/item_variant.py index ae99d316bfe..4311af0b79a 100644 --- a/erpnext/controllers/item_variant.py +++ b/erpnext/controllers/item_variant.py @@ -131,7 +131,7 @@ def find_variant(template, args, variant_item_code=None): conditions = " or ".join(conditions) - from erpnext.portal.product_configurator.utils import get_item_codes_by_attributes + from erpnext.e_commerce.product_configurator.utils import get_item_codes_by_attributes possible_variants = [i for i in get_item_codes_by_attributes(args, template) if i != variant_item_code] for variant in possible_variants: diff --git a/erpnext/e_commerce/doctype/website_item/website_item.py b/erpnext/e_commerce/doctype/website_item/website_item.py index 5587af7fd3c..e3197b9fb0d 100644 --- a/erpnext/e_commerce/doctype/website_item/website_item.py +++ b/erpnext/e_commerce/doctype/website_item/website_item.py @@ -314,7 +314,7 @@ class WebsiteItem(WebsiteGenerator): context.metatags['og:site_name'] = 'ERPNext' def set_shopping_cart_data(self, context): - from erpnext.shopping_cart.product_info import get_product_info_for_website + from erpnext.e_commerce.shopping_cart.product_info import get_product_info_for_website context.shopping_cart = get_product_info_for_website(self.item_code, skip_quotation_creation=True) def copy_specification_from_item_group(self): diff --git a/erpnext/shopping_cart/filters.py b/erpnext/e_commerce/filters.py similarity index 90% rename from erpnext/shopping_cart/filters.py rename to erpnext/e_commerce/filters.py index 4021e3f86f7..997c7dae8d3 100644 --- a/erpnext/shopping_cart/filters.py +++ b/erpnext/e_commerce/filters.py @@ -15,7 +15,7 @@ class ProductFiltersBuilder: self.item_group = item_group def get_field_filters(self): - if not self.doc.enable_field_filters: return + if not self.item_group and not self.doc.enable_field_filters: return filter_fields = [row.fieldname for row in self.doc.filter_fields] @@ -29,7 +29,7 @@ class ProductFiltersBuilder: if self.item_group: filters['item_group'] = self.item_group - values = frappe.get_all("Item", fields=[df.fieldname], filters=filters, distinct="True", pluck=df.fieldname, debug=1) + values = frappe.get_all("Item", fields=[df.fieldname], filters=filters, distinct="True", pluck=df.fieldname) else: doctype = df.get_link_doctype() @@ -53,8 +53,8 @@ class ProductFiltersBuilder: return filter_data - def get_attribute_fitlers(self): - if not self.doc.enable_attribute_filters: return + def get_attribute_filters(self): + if not self.item_group and not self.doc.enable_attribute_filters: return attributes = [row.attribute for row in self.doc.filter_attributes] attribute_docs = [ diff --git a/erpnext/portal/product_configurator/__init__.py b/erpnext/e_commerce/product_configurator/__init__.py similarity index 100% rename from erpnext/portal/product_configurator/__init__.py rename to erpnext/e_commerce/product_configurator/__init__.py diff --git a/erpnext/portal/product_configurator/item_variants_cache.py b/erpnext/e_commerce/product_configurator/item_variants_cache.py similarity index 100% rename from erpnext/portal/product_configurator/item_variants_cache.py rename to erpnext/e_commerce/product_configurator/item_variants_cache.py diff --git a/erpnext/portal/product_configurator/test_product_configurator.py b/erpnext/e_commerce/product_configurator/test_product_configurator.py similarity index 64% rename from erpnext/portal/product_configurator/test_product_configurator.py rename to erpnext/e_commerce/product_configurator/test_product_configurator.py index 397fbe3d0d5..b8698930613 100644 --- a/erpnext/portal/product_configurator/test_product_configurator.py +++ b/erpnext/e_commerce/product_configurator/test_product_configurator.py @@ -4,18 +4,21 @@ from bs4 import BeautifulSoup import frappe, unittest from frappe.utils import set_request, get_html_for_route from frappe.website.render import render -from erpnext.portal.product_configurator.utils import get_products_for_website +from erpnext.e_commerce.product_query import ProductQuery from erpnext.stock.doctype.item.test_item import make_item_variant +from erpnext.e_commerce.doctype.website_item.website_item import make_website_item test_dependencies = ["Item"] class TestProductConfigurator(unittest.TestCase): def setUp(self): self.create_variant_item() + self.publish_items_on_website() def test_product_list(self): - template_items = frappe.get_all('Item', {'show_in_website': 1}) - variant_items = frappe.get_all('Item', {'show_variant_in_website': 1}) + usual_items = frappe.get_all('Website Item', {'published': 1, 'has_variants': 0, 'variant_of': ['is', 'not set']}) + template_items = frappe.get_all('Website Item', {'published': 1, 'has_variants': 1}) + variant_items = frappe.get_all('Website Item', {'published': 1, 'variant_of': ['is', 'set']}) e_commerce_settings = frappe.get_doc('E Commerce Settings') e_commerce_settings.enable_field_filters = 1 @@ -28,10 +31,10 @@ class TestProductConfigurator(unittest.TestCase): soup = BeautifulSoup(html, 'html.parser') products_list = soup.find(class_='products-list') items = products_list.find_all(class_='card') - self.assertEqual(len(items), len(template_items + variant_items)) - items_with_item_group = frappe.get_all('Item', {'item_group': '_Test Item Group Desktops', 'show_in_website': 1}) - variants_with_item_group = frappe.get_all('Item', {'item_group': '_Test Item Group Desktops', 'show_variant_in_website': 1}) + self.assertEqual(len(items), len(template_items + variant_items + usual_items)) + + items_with_item_group = frappe.get_all('Website Item', {'item_group': '_Test Item Group Desktops', 'published': 1}) # mock query params frappe.form_dict = frappe._dict({ @@ -41,11 +44,12 @@ class TestProductConfigurator(unittest.TestCase): soup = BeautifulSoup(html, 'html.parser') products_list = soup.find(class_='products-list') items = products_list.find_all(class_='card') - self.assertEqual(len(items), len(items_with_item_group + variants_with_item_group)) + self.assertEqual(len(items), len(items_with_item_group)) def test_get_products_for_website(self): - items = get_products_for_website(attribute_filters={ + engine = ProductQuery() + items = engine.query(attributes={ 'Test Size': ['Medium'] }) self.assertEqual(len(items), 1) @@ -75,10 +79,17 @@ class TestProductConfigurator(unittest.TestCase): "attribute": "Test Size", "attribute_value": "Medium" } - ], - "show_variant_in_website": 1 + ] }).insert() + def publish_items_on_website(self): + if frappe.db.exists("Item", "_Test Item") and not frappe.db.exists("Website Item", {"item_code": "_Test Item"}): + make_website_item(frappe.get_cached_doc("Item", "_Test Item")) + + if frappe.db.exists("Item", "_Test Variant Item") and not frappe.db.exists("Website Item", {"item_code": "_Test Variant Item"}): + make_website_item(frappe.get_cached_doc("Item", "_Test Variant Item")) + + make_website_item(frappe.get_cached_doc("Item", "_Test Variant Item 1")) def tearDown(self): frappe.db.rollback() \ No newline at end of file diff --git a/erpnext/portal/product_configurator/utils.py b/erpnext/e_commerce/product_configurator/utils.py similarity index 75% rename from erpnext/portal/product_configurator/utils.py rename to erpnext/e_commerce/product_configurator/utils.py index cca36025160..010e1576d50 100644 --- a/erpnext/portal/product_configurator/utils.py +++ b/erpnext/e_commerce/product_configurator/utils.py @@ -1,7 +1,64 @@ import frappe from frappe.utils import cint -from erpnext.portal.product_configurator.item_variants_cache import ItemVariantsCacheManager -from erpnext.shopping_cart.product_info import get_product_info_for_website +from erpnext.e_commerce.product_configurator.item_variants_cache import ItemVariantsCacheManager +from erpnext.e_commerce.shopping_cart.product_info import get_product_info_for_website + +def get_item_codes_by_attributes(attribute_filters, template_item_code=None): + items = [] + + for attribute, values in attribute_filters.items(): + attribute_values = values + + if not isinstance(attribute_values, list): + attribute_values = [attribute_values] + + if not attribute_values: continue + + wheres = [] + query_values = [] + for attribute_value in attribute_values: + wheres.append('( attribute = %s and attribute_value = %s )') + query_values += [attribute, attribute_value] + + attribute_query = ' or '.join(wheres) + + if template_item_code: + variant_of_query = 'AND t2.variant_of = %s' + query_values.append(template_item_code) + else: + variant_of_query = '' + + query = ''' + SELECT + t1.parent + FROM + `tabItem Variant Attribute` t1 + WHERE + 1 = 1 + AND ( + {attribute_query} + ) + AND EXISTS ( + SELECT + 1 + FROM + `tabItem` t2 + WHERE + t2.name = t1.parent + {variant_of_query} + ) + GROUP BY + t1.parent + ORDER BY + NULL + '''.format(attribute_query=attribute_query, variant_of_query=variant_of_query) + + item_codes = set([r[0] for r in frappe.db.sql(query, query_values)]) + items.append(item_codes) + + res = list(set.intersection(*items)) + + return res @frappe.whitelist(allow_guest=True) def get_attributes_and_values(item_code): @@ -84,7 +141,7 @@ def get_next_attribute_and_values(item_code, selected_attributes): filtered_items_count = len(filtered_items) # get product info if exact match - from erpnext.shopping_cart.product_info import get_product_info_for_website + from erpnext.e_commerce.shopping_cart.product_info import get_product_info_for_website if exact_match: data = get_product_info_for_website(exact_match[0]) product_info = data.product_info diff --git a/erpnext/shopping_cart/product_query.py b/erpnext/e_commerce/product_query.py similarity index 98% rename from erpnext/shopping_cart/product_query.py rename to erpnext/e_commerce/product_query.py index 42152a15a92..36a17d7260c 100644 --- a/erpnext/shopping_cart/product_query.py +++ b/erpnext/e_commerce/product_query.py @@ -2,7 +2,7 @@ # License: GNU General Public License v3. See license.txt import frappe -from erpnext.shopping_cart.product_info import get_product_info_for_website +from erpnext.e_commerce.shopping_cart.product_info import get_product_info_for_website class ProductQuery: """Query engine for product listing diff --git a/erpnext/shopping_cart/web_template/hero_slider/__init__.py b/erpnext/e_commerce/shopping_cart/__init__.py similarity index 100% rename from erpnext/shopping_cart/web_template/hero_slider/__init__.py rename to erpnext/e_commerce/shopping_cart/__init__.py diff --git a/erpnext/shopping_cart/cart.py b/erpnext/e_commerce/shopping_cart/cart.py similarity index 100% rename from erpnext/shopping_cart/cart.py rename to erpnext/e_commerce/shopping_cart/cart.py diff --git a/erpnext/shopping_cart/product_info.py b/erpnext/e_commerce/shopping_cart/product_info.py similarity index 96% rename from erpnext/shopping_cart/product_info.py rename to erpnext/e_commerce/shopping_cart/product_info.py index c58a1be572d..6f6379b279a 100644 --- a/erpnext/shopping_cart/product_info.py +++ b/erpnext/e_commerce/shopping_cart/product_info.py @@ -4,7 +4,7 @@ from __future__ import unicode_literals import frappe -from erpnext.shopping_cart.cart import _get_cart_quotation, _set_price_list +from erpnext.e_commerce.shopping_cart.cart import _get_cart_quotation, _set_price_list from erpnext.e_commerce.doctype.e_commerce_settings.e_commerce_settings \ import get_shopping_cart_settings, show_quantity_in_website from erpnext.utilities.product import get_price, get_qty_in_stock, get_non_stock_item_status diff --git a/erpnext/shopping_cart/search.py b/erpnext/e_commerce/shopping_cart/search.py similarity index 100% rename from erpnext/shopping_cart/search.py rename to erpnext/e_commerce/shopping_cart/search.py diff --git a/erpnext/shopping_cart/test_shopping_cart.py b/erpnext/e_commerce/shopping_cart/test_shopping_cart.py similarity index 93% rename from erpnext/shopping_cart/test_shopping_cart.py rename to erpnext/e_commerce/shopping_cart/test_shopping_cart.py index be62755b6ac..b502405e41c 100644 --- a/erpnext/shopping_cart/test_shopping_cart.py +++ b/erpnext/e_commerce/shopping_cart/test_shopping_cart.py @@ -5,8 +5,9 @@ from __future__ import unicode_literals import unittest import frappe from frappe.utils import nowdate, add_months -from erpnext.shopping_cart.cart import _get_cart_quotation, update_cart, get_party from erpnext.tests.utils import create_test_contact_and_address +from erpnext.e_commerce.doctype.website_item.website_item import make_website_item +from erpnext.e_commerce.shopping_cart.cart import _get_cart_quotation, update_cart, get_party # test_dependencies = ['Payment Terms Template'] @@ -20,6 +21,11 @@ class TestShoppingCart(unittest.TestCase): frappe.set_user("Administrator") create_test_contact_and_address() self.enable_shopping_cart() + if not frappe.db.exists("Website Item", {"item_code": "_Test Item"}): + make_website_item(frappe.get_cached_doc("Item", "_Test Item")) + + if not frappe.db.exists("Website Item", {"item_code": "_Test Item 2"}): + make_website_item(frappe.get_cached_doc("Item", "_Test Item 2")) def tearDown(self): frappe.set_user("Administrator") diff --git a/erpnext/shopping_cart/utils.py b/erpnext/e_commerce/shopping_cart/utils.py similarity index 94% rename from erpnext/shopping_cart/utils.py rename to erpnext/e_commerce/shopping_cart/utils.py index 919131f7eec..783c025dd56 100644 --- a/erpnext/shopping_cart/utils.py +++ b/erpnext/e_commerce/shopping_cart/utils.py @@ -18,7 +18,7 @@ def set_cart_count(login_manager): role, parties = check_customer_or_supplier() if role == 'Supplier': return if show_cart_count(): - from erpnext.shopping_cart.cart import set_cart_count + from erpnext.e_commerce.shopping_cart.cart import set_cart_count set_cart_count() def clear_cart_count(login_manager): diff --git a/erpnext/shopping_cart/web_template/item_card_group/__init__.py b/erpnext/e_commerce/web_template/__init__.py similarity index 100% rename from erpnext/shopping_cart/web_template/item_card_group/__init__.py rename to erpnext/e_commerce/web_template/__init__.py diff --git a/erpnext/shopping_cart/web_template/product_card/__init__.py b/erpnext/e_commerce/web_template/hero_slider/__init__.py similarity index 100% rename from erpnext/shopping_cart/web_template/product_card/__init__.py rename to erpnext/e_commerce/web_template/hero_slider/__init__.py diff --git a/erpnext/shopping_cart/web_template/hero_slider/hero_slider.html b/erpnext/e_commerce/web_template/hero_slider/hero_slider.html similarity index 100% rename from erpnext/shopping_cart/web_template/hero_slider/hero_slider.html rename to erpnext/e_commerce/web_template/hero_slider/hero_slider.html diff --git a/erpnext/shopping_cart/web_template/hero_slider/hero_slider.json b/erpnext/e_commerce/web_template/hero_slider/hero_slider.json similarity index 98% rename from erpnext/shopping_cart/web_template/hero_slider/hero_slider.json rename to erpnext/e_commerce/web_template/hero_slider/hero_slider.json index 04fb1d27059..2b1807c9651 100644 --- a/erpnext/shopping_cart/web_template/hero_slider/hero_slider.json +++ b/erpnext/e_commerce/web_template/hero_slider/hero_slider.json @@ -1,4 +1,5 @@ { + "__unsaved": 1, "creation": "2020-11-17 15:21:51.207221", "docstatus": 0, "doctype": "Web Template", @@ -273,9 +274,9 @@ } ], "idx": 2, - "modified": "2020-12-29 12:30:02.794994", + "modified": "2021-02-24 15:57:05.889709", "modified_by": "Administrator", - "module": "Shopping Cart", + "module": "E-commerce", "name": "Hero Slider", "owner": "Administrator", "standard": 1, diff --git a/erpnext/shopping_cart/web_template/product_category_cards/__init__.py b/erpnext/e_commerce/web_template/item_card_group/__init__.py similarity index 100% rename from erpnext/shopping_cart/web_template/product_category_cards/__init__.py rename to erpnext/e_commerce/web_template/item_card_group/__init__.py diff --git a/erpnext/shopping_cart/web_template/item_card_group/item_card_group.html b/erpnext/e_commerce/web_template/item_card_group/item_card_group.html similarity index 100% rename from erpnext/shopping_cart/web_template/item_card_group/item_card_group.html rename to erpnext/e_commerce/web_template/item_card_group/item_card_group.html diff --git a/erpnext/shopping_cart/web_template/item_card_group/item_card_group.json b/erpnext/e_commerce/web_template/item_card_group/item_card_group.json similarity index 97% rename from erpnext/shopping_cart/web_template/item_card_group/item_card_group.json rename to erpnext/e_commerce/web_template/item_card_group/item_card_group.json index ad087b04704..724c4379121 100644 --- a/erpnext/shopping_cart/web_template/item_card_group/item_card_group.json +++ b/erpnext/e_commerce/web_template/item_card_group/item_card_group.json @@ -17,15 +17,12 @@ "reqd": 0 }, { - "__unsaved": 1, "fieldname": "primary_action_label", "fieldtype": "Data", "label": "Primary Action Label", "reqd": 0 }, { - "__islocal": 1, - "__unsaved": 1, "fieldname": "primary_action", "fieldtype": "Data", "label": "Primary Action", @@ -262,9 +259,9 @@ } ], "idx": 0, - "modified": "2020-11-19 18:48:52.633045", + "modified": "2021-02-24 16:05:31.242342", "modified_by": "Administrator", - "module": "Shopping Cart", + "module": "E-commerce", "name": "Item Card Group", "owner": "Administrator", "standard": 1, diff --git a/erpnext/shopping_cart/web_template/product_card/product_card.html b/erpnext/e_commerce/web_template/product_card/__init__.py similarity index 100% rename from erpnext/shopping_cart/web_template/product_card/product_card.html rename to erpnext/e_commerce/web_template/product_card/__init__.py diff --git a/erpnext/e_commerce/web_template/product_card/product_card.html b/erpnext/e_commerce/web_template/product_card/product_card.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/erpnext/shopping_cart/web_template/product_card/product_card.json b/erpnext/e_commerce/web_template/product_card/product_card.json similarity index 82% rename from erpnext/shopping_cart/web_template/product_card/product_card.json rename to erpnext/e_commerce/web_template/product_card/product_card.json index 1059c1b2519..2eb73741efb 100644 --- a/erpnext/shopping_cart/web_template/product_card/product_card.json +++ b/erpnext/e_commerce/web_template/product_card/product_card.json @@ -5,7 +5,6 @@ "doctype": "Web Template", "fields": [ { - "__unsaved": 1, "fieldname": "item", "fieldtype": "Link", "label": "Item", @@ -13,7 +12,6 @@ "reqd": 0 }, { - "__unsaved": 1, "fieldname": "featured", "fieldtype": "Check", "label": "Featured", @@ -22,9 +20,9 @@ } ], "idx": 0, - "modified": "2020-11-17 15:33:34.982515", + "modified": "2021-02-24 16:05:17.926610", "modified_by": "Administrator", - "module": "Shopping Cart", + "module": "E-commerce", "name": "Product Card", "owner": "Administrator", "standard": 1, diff --git a/erpnext/e_commerce/web_template/product_category_cards/__init__.py b/erpnext/e_commerce/web_template/product_category_cards/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/erpnext/shopping_cart/web_template/product_category_cards/product_category_cards.html b/erpnext/e_commerce/web_template/product_category_cards/product_category_cards.html similarity index 100% rename from erpnext/shopping_cart/web_template/product_category_cards/product_category_cards.html rename to erpnext/e_commerce/web_template/product_category_cards/product_category_cards.html diff --git a/erpnext/shopping_cart/web_template/product_category_cards/product_category_cards.json b/erpnext/e_commerce/web_template/product_category_cards/product_category_cards.json similarity index 95% rename from erpnext/shopping_cart/web_template/product_category_cards/product_category_cards.json rename to erpnext/e_commerce/web_template/product_category_cards/product_category_cards.json index ba5f63b48b2..0202165d08e 100644 --- a/erpnext/shopping_cart/web_template/product_category_cards/product_category_cards.json +++ b/erpnext/e_commerce/web_template/product_category_cards/product_category_cards.json @@ -74,9 +74,9 @@ } ], "idx": 0, - "modified": "2020-11-18 17:26:28.726260", + "modified": "2021-02-24 16:03:33.835635", "modified_by": "Administrator", - "module": "Shopping Cart", + "module": "E-commerce", "name": "Product Category Cards", "owner": "Administrator", "standard": 1, diff --git a/erpnext/hooks.py b/erpnext/hooks.py index 3ece8c1bfbe..53cf9c6018b 100644 --- a/erpnext/hooks.py +++ b/erpnext/hooks.py @@ -50,15 +50,15 @@ additional_print_settings = "erpnext.controllers.print_settings.get_print_settin on_session_creation = [ "erpnext.portal.utils.create_customer_or_supplier", - "erpnext.shopping_cart.utils.set_cart_count" + "erpnext.e_commerce.shopping_cart.utils.set_cart_count" ] -on_logout = "erpnext.shopping_cart.utils.clear_cart_count" +on_logout = "erpnext.e_commerce.shopping_cart.utils.clear_cart_count" treeviews = ['Account', 'Cost Center', 'Warehouse', 'Item Group', 'Customer Group', 'Sales Person', 'Territory', 'Assessment Group', 'Department'] # website -update_website_context = ["erpnext.shopping_cart.utils.update_website_context", "erpnext.education.doctype.education_settings.education_settings.update_website_context"] -my_account_context = "erpnext.shopping_cart.utils.update_my_account_context" +update_website_context = ["erpnext.e_commerce.shopping_cart.utils.update_website_context", "erpnext.education.doctype.education_settings.education_settings.update_website_context"] +my_account_context = "erpnext.e_commerce.shopping_cart.utils.update_my_account_context" calendars = ["Task", "Work Order", "Leave Application", "Sales Order", "Holiday List", "Course Schedule"] diff --git a/erpnext/modules.txt b/erpnext/modules.txt index f31a3c1e99a..3ffa5f292cc 100644 --- a/erpnext/modules.txt +++ b/erpnext/modules.txt @@ -9,7 +9,6 @@ Manufacturing Stock Support Utilities -Shopping Cart Assets Portal Maintenance diff --git a/erpnext/patches/v13_0/populate_e_commerce_settings.py b/erpnext/patches/v13_0/populate_e_commerce_settings.py index 94dcd9a3ed4..19f91ef1e2a 100644 --- a/erpnext/patches/v13_0/populate_e_commerce_settings.py +++ b/erpnext/patches/v13_0/populate_e_commerce_settings.py @@ -32,7 +32,7 @@ def execute(): """.format( doctype=doctype, fields=(",").join(['%s'] * len(fields)) - ), tuple(fields), as_dict=1, debug=1) + ), tuple(fields), as_dict=1) # {'enable_attribute_filters': '1', ...} mapper = {row.field: row.value for row in data} diff --git a/erpnext/portal/utils.py b/erpnext/portal/utils.py index 3f8025fa837..c459f8b9d65 100644 --- a/erpnext/portal/utils.py +++ b/erpnext/portal/utils.py @@ -1,7 +1,7 @@ from __future__ import unicode_literals import frappe from erpnext.e_commerce.doctype.e_commerce_settings.e_commerce_settings import get_shopping_cart_settings -from erpnext.shopping_cart.cart import get_debtors_account +from erpnext.e_commerce.shopping_cart.cart import get_debtors_account from frappe.utils.nestedset import get_root_of def set_default_role(doc, method): diff --git a/erpnext/public/js/conf.js b/erpnext/public/js/conf.js index eb709e5e85e..a0f56a2d07f 100644 --- a/erpnext/public/js/conf.js +++ b/erpnext/public/js/conf.js @@ -21,6 +21,6 @@ $.extend(frappe.breadcrumbs.module_map, { 'Geo': 'Settings', 'Portal': 'Website', 'Utilities': 'Settings', - 'Shopping Cart': 'Website', + 'E-commerce': 'Website', 'Contacts': 'CRM' }); diff --git a/erpnext/public/js/shopping_cart.js b/erpnext/public/js/shopping_cart.js index 227881ac2a0..6553801de09 100644 --- a/erpnext/public/js/shopping_cart.js +++ b/erpnext/public/js/shopping_cart.js @@ -63,7 +63,7 @@ $.extend(shopping_cart, { $(".shopping-cart").on('shown.bs.dropdown', function() { if (!$('.shopping-cart-menu .cart-container').length) { return frappe.call({ - method: 'erpnext.shopping_cart.cart.get_shopping_cart_menu', + method: 'erpnext.e_commerce.shopping_cart.cart.get_shopping_cart_menu', callback: function(r) { if (r.message) { $('.shopping-cart-menu').html(r.message); @@ -83,7 +83,7 @@ $.extend(shopping_cart, { } else { return frappe.call({ type: "POST", - method: "erpnext.shopping_cart.cart.update_cart", + method: "erpnext.e_commerce.shopping_cart.cart.update_cart", args: { item_code: opts.item_code, qty: opts.qty, diff --git a/erpnext/setup/doctype/item_group/item_group.py b/erpnext/setup/doctype/item_group/item_group.py index 85937c9f930..64654805344 100644 --- a/erpnext/setup/doctype/item_group/item_group.py +++ b/erpnext/setup/doctype/item_group/item_group.py @@ -10,11 +10,10 @@ from frappe.utils.nestedset import NestedSet from frappe.website.website_generator import WebsiteGenerator from frappe.website.render import clear_cache from frappe.website.doctype.website_slideshow.website_slideshow import get_slideshow -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 +from erpnext.e_commerce.product_query import ProductQuery +from erpnext.e_commerce.filters import ProductFiltersBuilder class ItemGroup(NestedSet, WebsiteGenerator): nsm_parent_field = 'parent_item_group' @@ -96,7 +95,7 @@ class ItemGroup(NestedSet, WebsiteGenerator): filter_engine = ProductFiltersBuilder(self.name) context.field_filters = filter_engine.get_field_filters() - context.attribute_filters = filter_engine.get_attribute_fitlers() + context.attribute_filters = filter_engine.get_attribute_filters() context.update({ "parents": get_parent_item_groups(self.parent_item_group), diff --git a/erpnext/stock/doctype/item/item.json b/erpnext/stock/doctype/item/item.json index ff1c694cc32..6757d9503ea 100644 --- a/erpnext/stock/doctype/item/item.json +++ b/erpnext/stock/doctype/item/item.json @@ -116,12 +116,14 @@ "customer_code", "default_item_manufacturer", "default_manufacturer_part_no", - "total_projected_qty", "hub_publishing_sb", "publish_in_hub", "hub_category_to_publish", "hub_warehouse", - "synced_with_hub" + "synced_with_hub", + "more_information_section", + "published_in_website", + "total_projected_qty" ], "fields": [ { @@ -916,6 +918,20 @@ "fieldtype": "Data", "label": "Default Manufacturer Part No", "read_only": 1 + }, + { + "collapsible": 1, + "fieldname": "more_information_section", + "fieldtype": "Section Break", + "label": "More Information" + }, + { + "default": "0", + "depends_on": "published_in_website", + "fieldname": "published_in_website", + "fieldtype": "Check", + "label": "Published in Website", + "read_only": 1 } ], "icon": "fa fa-tag", @@ -924,7 +940,7 @@ "index_web_pages_for_search": 1, "links": [], "max_attachments": 1, - "modified": "2021-02-19 12:41:55.301730", + "modified": "2021-02-25 12:49:56.609383", "modified_by": "Administrator", "module": "Stock", "name": "Item", diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py index d6d7c56ad1d..d15d7f7430e 100644 --- a/erpnext/stock/doctype/item/item.py +++ b/erpnext/stock/doctype/item/item.py @@ -840,7 +840,7 @@ def invalidate_cache_for_item(doc): def invalidate_item_variants_cache_for_website(doc): """Rebuild ItemVariantsCacheManager via Item or Website Item.""" - from erpnext.portal.product_configurator.item_variants_cache import ItemVariantsCacheManager + from erpnext.e_commerce.product_configurator.item_variants_cache import ItemVariantsCacheManager item_code = None is_web_item = doc.get("published_in_website") or doc.get("published") diff --git a/erpnext/templates/generators/item/item_configure.js b/erpnext/templates/generators/item/item_configure.js index 8eadb842899..5cb5d155017 100644 --- a/erpnext/templates/generators/item/item_configure.js +++ b/erpnext/templates/generators/item/item_configure.js @@ -280,14 +280,14 @@ class ItemConfigure { } get_next_attribute_and_values(selected_attributes) { - return this.call('erpnext.portal.product_configurator.utils.get_next_attribute_and_values', { + return this.call('erpnext.e_commerce.product_configurator.utils.get_next_attribute_and_values', { item_code: this.item_code, selected_attributes }); } get_attributes_and_values() { - return this.call('erpnext.portal.product_configurator.utils.get_attributes_and_values', { + return this.call('erpnext.e_commerce.product_configurator.utils.get_attributes_and_values', { item_code: this.item_code }); } diff --git a/erpnext/templates/generators/item/item_inquiry.js b/erpnext/templates/generators/item/item_inquiry.js index e7db3a368df..c3e7b00862b 100644 --- a/erpnext/templates/generators/item/item_inquiry.js +++ b/erpnext/templates/generators/item/item_inquiry.js @@ -52,7 +52,7 @@ frappe.ready(() => { d.hide(); - frappe.call('erpnext.shopping_cart.cart.create_lead_for_item_inquiry', { + frappe.call('erpnext.e_commerce.shopping_cart.cart.create_lead_for_item_inquiry', { lead: doc, subject: values.subject, message: values.message diff --git a/erpnext/templates/includes/cart.js b/erpnext/templates/includes/cart.js index c390cd171d3..4de8ff788c2 100644 --- a/erpnext/templates/includes/cart.js +++ b/erpnext/templates/includes/cart.js @@ -48,7 +48,7 @@ $.extend(shopping_cart, { const address_name = $card.closest('[data-address-name]').attr('data-address-name'); frappe.call({ type: "POST", - method: "erpnext.shopping_cart.cart.update_cart_address", + method: "erpnext.e_commerce.shopping_cart.cart.update_cart_address", freeze: true, args: { address_type, @@ -185,7 +185,7 @@ $.extend(shopping_cart, { return frappe.call({ btn: btn, type: "POST", - method: "erpnext.shopping_cart.cart.apply_shipping_rule", + method: "erpnext.e_commerce.shopping_cart.cart.apply_shipping_rule", args: { shipping_rule: rule }, callback: function(r) { if(!r.exc) { @@ -198,7 +198,7 @@ $.extend(shopping_cart, { place_order: function(btn) { return frappe.call({ type: "POST", - method: "erpnext.shopping_cart.cart.place_order", + method: "erpnext.e_commerce.shopping_cart.cart.place_order", btn: btn, callback: function(r) { if(r.exc) { @@ -223,7 +223,7 @@ $.extend(shopping_cart, { request_quotation: function(btn) { return frappe.call({ type: "POST", - method: "erpnext.shopping_cart.cart.request_for_quotation", + method: "erpnext.e_commerce.shopping_cart.cart.request_for_quotation", btn: btn, callback: function(r) { if(r.exc) { @@ -254,7 +254,7 @@ $.extend(shopping_cart, { apply_coupon_code: function(btn) { return frappe.call({ type: "POST", - method: "erpnext.shopping_cart.cart.apply_coupon_code", + method: "erpnext.e_commerce.shopping_cart.cart.apply_coupon_code", btn: btn, args : { applied_code : $('.txtcoupon').val(), diff --git a/erpnext/templates/includes/cart/cart_address.html b/erpnext/templates/includes/cart/cart_address.html index 6a9f0f6b04e..aad067a3f67 100644 --- a/erpnext/templates/includes/cart/cart_address.html +++ b/erpnext/templates/includes/cart/cart_address.html @@ -129,10 +129,10 @@ frappe.ready(() => { ], primary_action_label: __('Save'), primary_action: (values) => { - frappe.call('erpnext.shopping_cart.cart.add_new_address', { doc: values }) + frappe.call('erpnext.e_commerce.shopping_cart.cart.add_new_address', { doc: values }) .then(r => { frappe.call({ - method: "erpnext.shopping_cart.cart.update_cart_address", + method: "erpnext.e_commerce.shopping_cart.cart.update_cart_address", args: { address_type: r.message.address_type, address_name: r.message.name diff --git a/erpnext/templates/includes/product_page.js b/erpnext/templates/includes/product_page.js index 90a1d862c3d..a3979d037b6 100644 --- a/erpnext/templates/includes/product_page.js +++ b/erpnext/templates/includes/product_page.js @@ -7,7 +7,7 @@ frappe.ready(function() { frappe.call({ type: "POST", - method: "erpnext.shopping_cart.product_info.get_product_info_for_website", + method: "erpnext.e_commerce.shopping_cart.product_info.get_product_info_for_website", args: { item_code: get_item_code() }, diff --git a/erpnext/templates/pages/cart.html b/erpnext/templates/pages/cart.html index ea343713a13..87d2d4034a1 100644 --- a/erpnext/templates/pages/cart.html +++ b/erpnext/templates/pages/cart.html @@ -96,7 +96,7 @@ }) }); function show_terms_and_conditions(terms_name) { - frappe.call('erpnext.shopping_cart.cart.get_terms_and_conditions', { terms_name }) + frappe.call('erpnext.e_commerce.shopping_cart.cart.get_terms_and_conditions', { terms_name }) .then(r => { frappe.msgprint({ title: terms_name, diff --git a/erpnext/templates/pages/cart.py b/erpnext/templates/pages/cart.py index 30b03575785..502c3aec290 100644 --- a/erpnext/templates/pages/cart.py +++ b/erpnext/templates/pages/cart.py @@ -5,7 +5,7 @@ from __future__ import unicode_literals no_cache = 1 import frappe -from erpnext.shopping_cart.cart import get_cart_quotation +from erpnext.e_commerce.shopping_cart.cart import get_cart_quotation def get_context(context): context.update(get_cart_quotation()) diff --git a/erpnext/templates/pages/product_search.py b/erpnext/templates/pages/product_search.py index d0d72f073a9..4f4d95bc473 100644 --- a/erpnext/templates/pages/product_search.py +++ b/erpnext/templates/pages/product_search.py @@ -5,7 +5,7 @@ from __future__ import unicode_literals import frappe from frappe.utils import cstr, nowdate, cint from erpnext.setup.doctype.item_group.item_group import get_item_for_list_in_html -from erpnext.shopping_cart.product_info import set_product_info_for_website +from erpnext.e_commerce.shopping_cart.product_info import set_product_info_for_website no_cache = 1 diff --git a/erpnext/www/all-products/index.py b/erpnext/www/all-products/index.py index c0af1d31d6d..d0871fc14e0 100644 --- a/erpnext/www/all-products/index.py +++ b/erpnext/www/all-products/index.py @@ -1,7 +1,7 @@ import frappe from frappe.utils import cint -from erpnext.shopping_cart.product_query import ProductQuery -from erpnext.shopping_cart.filters import ProductFiltersBuilder +from erpnext.e_commerce.product_query import ProductQuery +from erpnext.e_commerce.filters import ProductFiltersBuilder sitemap = 1 @@ -25,7 +25,7 @@ def get_context(context): filter_engine = ProductFiltersBuilder() context.field_filters = filter_engine.get_field_filters() - context.attribute_filters = filter_engine.get_attribute_fitlers() + context.attribute_filters = filter_engine.get_attribute_filters() context.e_commerce_settings = engine.settings context.body_class = "product-page"