From 025574d9b57bebbe63a3604b84b84d3cc42d1f23 Mon Sep 17 00:00:00 2001 From: marination Date: Fri, 19 Feb 2021 12:50:01 +0530 Subject: [PATCH] chore: Removing Item's Website section & references MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Removed old onboarding slide json and `create_onboarding_docs` methods - Removed website sections from Item master - Removed references to item website fields - Shifted Item doctype website methods to Website Item - Removed WebsiteGenerator from Item doctype - Website Items in Homepage Products section - Removed redundant code from item_group.py - Fix: Item field filters won’t appear in website --- .../doctype/coupon_code/test_coupon_code.py | 2 - erpnext/buying/doctype/supplier/supplier.py | 22 - .../add_a_few_suppliers.json | 49 -- erpnext/controllers/item_variant.py | 5 +- erpnext/demo/data/drug_list.json | 63 --- .../doctype/website_item/website_item.js | 15 +- .../doctype/website_item/website_item.json | 5 +- .../doctype/website_item/website_item.py | 42 +- erpnext/hooks.py | 2 +- erpnext/portal/doctype/homepage/homepage.js | 9 +- erpnext/portal/doctype/homepage/homepage.json | 439 ++---------------- erpnext/portal/doctype/homepage/homepage.py | 2 +- .../homepage_featured_product.json | 10 +- .../website_attribute/website_attribute.json | 98 ++-- erpnext/selling/doctype/customer/customer.py | 24 - .../add_a_few_customers.json | 49 -- .../setup/doctype/item_group/item_group.py | 87 ---- .../welcome_back_to_erpnext!.json | 23 - .../welcome_to_erpnext!.json | 23 - erpnext/shopping_cart/filters.py | 3 +- erpnext/shopping_cart/search.py | 2 +- erpnext/stock/doctype/item/item.js | 23 +- erpnext/stock/doctype/item/item.json | 147 ------ erpnext/stock/doctype/item/item.py | 80 +--- erpnext/stock/doctype/item/test_records.json | 13 +- .../item_variant_settings.js | 5 +- .../item_variant_settings.py | 6 +- .../add_a_few_products_you_buy_or_sell.json | 52 --- 28 files changed, 139 insertions(+), 1161 deletions(-) delete mode 100644 erpnext/buying/onboarding_slide/add_a_few_suppliers/add_a_few_suppliers.json delete mode 100644 erpnext/selling/onboarding_slide/add_a_few_customers/add_a_few_customers.json delete mode 100644 erpnext/setup/onboarding_slide/welcome_back_to_erpnext!/welcome_back_to_erpnext!.json delete mode 100644 erpnext/setup/onboarding_slide/welcome_to_erpnext!/welcome_to_erpnext!.json delete mode 100644 erpnext/stock/onboarding_slide/add_a_few_products_you_buy_or_sell/add_a_few_products_you_buy_or_sell.json diff --git a/erpnext/accounts/doctype/coupon_code/test_coupon_code.py b/erpnext/accounts/doctype/coupon_code/test_coupon_code.py index bf8c014a5b..b27f4eb503 100644 --- a/erpnext/accounts/doctype/coupon_code/test_coupon_code.py +++ b/erpnext/accounts/doctype/coupon_code/test_coupon_code.py @@ -41,9 +41,7 @@ def test_create_test_data(): "selling_cost_center": "Main - _TC", "income_account": "Sales - _TC" }], - "show_in_website": 1, "route":"-test-tesla-car", - "website_warehouse": "Stores - _TC" }) item.insert() # create test item price diff --git a/erpnext/buying/doctype/supplier/supplier.py b/erpnext/buying/doctype/supplier/supplier.py index 0ab01712e3..1a34be063b 100644 --- a/erpnext/buying/doctype/supplier/supplier.py +++ b/erpnext/buying/doctype/supplier/supplier.py @@ -128,28 +128,6 @@ class Supplier(TransactionBase): if frappe.defaults.get_global_default('supp_master_name') == 'Supplier Name': frappe.db.set(self, "supplier_name", newdn) - def create_onboarding_docs(self, args): - company = frappe.defaults.get_defaults().get('company') or \ - frappe.db.get_single_value('Global Defaults', 'default_company') - - for i in range(1, args.get('max_count')): - supplier = args.get('supplier_name_' + str(i)) - if supplier: - try: - doc = frappe.get_doc({ - 'doctype': self.doctype, - 'supplier_name': supplier, - 'supplier_group': _('Local'), - 'company': company - }).insert() - - if args.get('supplier_email_' + str(i)): - from erpnext.selling.doctype.customer.customer import create_contact - create_contact(supplier, 'Supplier', - doc.name, args.get('supplier_email_' + str(i))) - except frappe.NameError: - pass - @frappe.whitelist() @frappe.validate_and_sanitize_search_inputs def get_supplier_primary_contact(doctype, txt, searchfield, start, page_len, filters): diff --git a/erpnext/buying/onboarding_slide/add_a_few_suppliers/add_a_few_suppliers.json b/erpnext/buying/onboarding_slide/add_a_few_suppliers/add_a_few_suppliers.json deleted file mode 100644 index ce3d8cfb7b..0000000000 --- a/erpnext/buying/onboarding_slide/add_a_few_suppliers/add_a_few_suppliers.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "add_more_button": 1, - "app": "ERPNext", - "creation": "2019-11-15 14:45:32.626641", - "docstatus": 0, - "doctype": "Onboarding Slide", - "domains": [], - "help_links": [ - { - "label": "Learn More", - "video_id": "zsrrVDk6VBs" - } - ], - "idx": 0, - "image_src": "", - "is_completed": 0, - "max_count": 3, - "modified": "2019-12-09 17:54:18.452038", - "modified_by": "Administrator", - "name": "Add A Few Suppliers", - "owner": "Administrator", - "ref_doctype": "Supplier", - "slide_desc": "", - "slide_fields": [ - { - "align": "", - "fieldname": "supplier_name", - "fieldtype": "Data", - "label": "Supplier Name", - "placeholder": "", - "reqd": 1 - }, - { - "align": "", - "fieldtype": "Column Break", - "reqd": 0 - }, - { - "align": "", - "fieldname": "supplier_email", - "fieldtype": "Data", - "label": "Supplier Email", - "reqd": 1 - } - ], - "slide_order": 50, - "slide_title": "Add A Few Suppliers", - "slide_type": "Create" -} \ No newline at end of file diff --git a/erpnext/controllers/item_variant.py b/erpnext/controllers/item_variant.py index 1b56ae9d4d..6935fd7ab4 100644 --- a/erpnext/controllers/item_variant.py +++ b/erpnext/controllers/item_variant.py @@ -264,9 +264,8 @@ def generate_keyed_value_combinations(args): def copy_attributes_to_variant(item, variant): # copy non no-copy fields - exclude_fields = ["naming_series", "item_code", "item_name", "show_in_website", - "show_variant_in_website", "opening_stock", "variant_of", "valuation_rate", - "has_variants", "attributes"] + exclude_fields = ["naming_series", "item_code", "item_name", "published_in_website", + "opening_stock", "variant_of", "valuation_rate"] if item.variant_based_on=='Manufacturer': # don't copy manufacturer values if based on part no diff --git a/erpnext/demo/data/drug_list.json b/erpnext/demo/data/drug_list.json index e91c30d199..c7c06c946d 100644 --- a/erpnext/demo/data/drug_list.json +++ b/erpnext/demo/data/drug_list.json @@ -54,7 +54,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -138,7 +137,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -220,7 +218,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -302,7 +299,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -384,7 +380,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -466,7 +461,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -548,7 +542,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -630,7 +623,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -712,7 +704,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -794,7 +785,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -876,7 +866,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -958,7 +947,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -1040,7 +1028,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -1122,7 +1109,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -1204,7 +1190,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -1286,7 +1271,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -1368,7 +1352,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -1450,7 +1433,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -1532,7 +1514,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -1614,7 +1595,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -1696,7 +1676,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -1778,7 +1757,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -1860,7 +1838,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -1942,7 +1919,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -2024,7 +2000,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -2106,7 +2081,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -2188,7 +2162,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -2270,7 +2243,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -2352,7 +2324,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -2434,7 +2405,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -2516,7 +2486,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -2598,7 +2567,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -2680,7 +2648,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -2762,7 +2729,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -2844,7 +2810,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -2926,7 +2891,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -3008,7 +2972,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -3092,7 +3055,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -3174,7 +3136,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -3256,7 +3217,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -3338,7 +3298,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -3420,7 +3379,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -3502,7 +3460,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -3584,7 +3541,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -3666,7 +3622,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -3748,7 +3703,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -3830,7 +3784,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -3912,7 +3865,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -3994,7 +3946,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -4076,7 +4027,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -4158,7 +4108,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -4240,7 +4189,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -4322,7 +4270,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -4404,7 +4351,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -4486,7 +4432,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -4568,7 +4513,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -4650,7 +4594,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -4732,7 +4675,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -4814,7 +4756,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -4896,7 +4837,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -4978,7 +4918,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -5060,7 +4999,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, @@ -5142,7 +5080,6 @@ "safety_stock": 0.0, "selling_cost_center": null, "serial_no_series": null, - "show_in_website": 0, "show_variant_in_website": 0, "slideshow": null, "standard_rate": 0.0, diff --git a/erpnext/e_commerce/doctype/website_item/website_item.js b/erpnext/e_commerce/doctype/website_item/website_item.js index ecea74bc78..0d8a51e1de 100644 --- a/erpnext/e_commerce/doctype/website_item/website_item.js +++ b/erpnext/e_commerce/doctype/website_item/website_item.js @@ -2,7 +2,18 @@ // For license information, please see license.txt frappe.ui.form.on('Website Item', { - // refresh: function(frm) { + image: function() { + refresh_field("image_view"); + }, - // } + copy_from_item_group: function(frm) { + return frm.call({ + doc: frm.doc, + method: "copy_specification_from_item_group" + }); + }, + + set_meta_tags(frm) { + frappe.utils.set_meta_tag(frm.doc.route); + } }); diff --git a/erpnext/e_commerce/doctype/website_item/website_item.json b/erpnext/e_commerce/doctype/website_item/website_item.json index 02717eae14..3a2990639b 100644 --- a/erpnext/e_commerce/doctype/website_item/website_item.json +++ b/erpnext/e_commerce/doctype/website_item/website_item.json @@ -271,7 +271,7 @@ "image_field": "image", "index_web_pages_for_search": 1, "links": [], - "modified": "2021-02-12 16:49:42.275517", + "modified": "2021-02-18 13:23:18.286883", "modified_by": "Administrator", "module": "E-commerce", "name": "Website Item", @@ -290,9 +290,10 @@ "write": 1 } ], + "search_fields": "item_code, item_name ,item_group", "show_name_in_global_search": 1, "sort_field": "modified", "sort_order": "DESC", - "title_field": "web_item_name", + "title_field": "item_name", "track_changes": 1 } \ No newline at end of file diff --git a/erpnext/e_commerce/doctype/website_item/website_item.py b/erpnext/e_commerce/doctype/website_item/website_item.py index 55436f257d..51983ffd27 100644 --- a/erpnext/e_commerce/doctype/website_item/website_item.py +++ b/erpnext/e_commerce/doctype/website_item/website_item.py @@ -7,15 +7,12 @@ import frappe import json import itertools from frappe import _ -from six import iteritems -from frappe.website.doctype.website_slideshow.website_slideshow import \ - get_slideshow from frappe.website.render import clear_cache from frappe.website.website_generator import WebsiteGenerator -from frappe.utils import cstr, random_string, cint +from frappe.utils import cstr, random_string, cint, flt -from erpnext.setup.doctype.item_group.item_group import get_parent_item_groups +from erpnext.setup.doctype.item_group.item_group import (get_parent_item_groups, invalidate_cache_for) class WebsiteItem(WebsiteGenerator): website = frappe._dict( @@ -39,7 +36,13 @@ class WebsiteItem(WebsiteGenerator): self.make_thumbnail() self.publish_unpublish_desk_item(publish=True) + if not self.get("__islocal"): + self.old_website_item_groups = frappe.db.sql_list("""select item_group + from `tabWebsite Item Group` + where parentfield='website_item_groups' and parenttype='Item' and parent=%s""", self.name) + def on_update(self): + invalidate_cache_for_web_item(self) self.update_template_item() def on_trash(self): @@ -69,10 +72,9 @@ class WebsiteItem(WebsiteGenerator): # show template template_item = frappe.get_doc("Item", self.variant_of) - if not template_item.published: - template_item.published = 1 + if not template_item.published_in_website: template_item.flags.ignore_permissions = True - template_item.save() + make_website_item(template_item) def validate_website_image(self): if frappe.flags.in_import: @@ -160,7 +162,6 @@ class WebsiteItem(WebsiteGenerator): self.thumbnail = file_doc.thumbnail_url def get_context(self, context): - print(context) context.show_search = True context.search_link = '/search' @@ -174,7 +175,6 @@ class WebsiteItem(WebsiteGenerator): self.set_disabled_attributes(context) self.set_metatags(context) self.set_shopping_cart_data(context) - print("IN WEB ITEM") return context @@ -317,6 +317,28 @@ class WebsiteItem(WebsiteGenerator): from erpnext.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): + self.set("website_specifications", []) + if self.item_group: + for label, desc in frappe.db.get_values("Item Website Specification", + {"parent": self.item_group}, ["label", "description"]): + row = self.append("website_specifications") + row.label = label + row.description = desc + +def invalidate_cache_for_web_item(doc): + from erpnext.stock.doctype.item.item import invalidate_item_variants_cache_for_website + + invalidate_cache_for(doc, doc.item_group) + + website_item_groups = list(set((doc.get("old_website_item_groups") or []) + + [d.item_group for d in doc.get({"doctype": "Website Item Group"}) if d.item_group])) + + for item_group in website_item_groups: + invalidate_cache_for(doc, item_group) + + invalidate_item_variants_cache_for_website(doc) + @frappe.whitelist() def make_website_item(doc): if not doc: diff --git a/erpnext/hooks.py b/erpnext/hooks.py index d0142d3d0d..735103678e 100644 --- a/erpnext/hooks.py +++ b/erpnext/hooks.py @@ -77,7 +77,7 @@ domains = { 'Services': 'erpnext.domains.services', } -website_generators = ["Item Group", "Item", "BOM", "Sales Partner", +website_generators = ["Item Group", "Website Item", "BOM", "Sales Partner", "Job Opening", "Student Admission"] website_context = { diff --git a/erpnext/portal/doctype/homepage/homepage.js b/erpnext/portal/doctype/homepage/homepage.js index c7c66e0055..ea34bb17e5 100644 --- a/erpnext/portal/doctype/homepage/homepage.js +++ b/erpnext/portal/doctype/homepage/homepage.js @@ -3,9 +3,9 @@ frappe.ui.form.on('Homepage', { setup: function(frm) { - frm.fields_dict["products"].grid.get_field("item_code").get_query = function(){ + frm.fields_dict["products"].grid.get_field("item").get_query = function(){ return { - filters: {'show_in_website': 1} + filters: {'published': 1} } } }, @@ -21,11 +21,10 @@ frappe.ui.form.on('Homepage', { }); frappe.ui.form.on('Homepage Featured Product', { - view: function(frm, cdt, cdn){ var child= locals[cdt][cdn] - if(child.item_code && frm.doc.products_url){ - window.location.href = frm.doc.products_url + '/' + encodeURIComponent(child.item_code); + if(child.item_code && child.route){ + window.open('/' + child.route, '_blank'); } } }); diff --git a/erpnext/portal/doctype/homepage/homepage.json b/erpnext/portal/doctype/homepage/homepage.json index ad27278dc6..73f816d4d4 100644 --- a/erpnext/portal/doctype/homepage/homepage.json +++ b/erpnext/portal/doctype/homepage/homepage.json @@ -1,518 +1,143 @@ { - "allow_copy": 0, - "allow_events_in_timeline": 0, - "allow_guest_to_view": 0, - "allow_import": 0, - "allow_rename": 0, - "autoname": "", + "actions": [], "beta": 1, "creation": "2016-04-22 05:27:52.109319", - "custom": 0, - "docstatus": 0, "doctype": "DocType", "document_type": "Setup", - "editable_grid": 0, "engine": "InnoDB", + "field_order": [ + "company", + "hero_section_based_on", + "column_break_2", + "title", + "section_break_4", + "tag_line", + "description", + "hero_image", + "slideshow", + "hero_section", + "products_section", + "products_url", + "products" + ], "fields": [ { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "company", "fieldtype": "Link", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, "in_list_view": 1, - "in_standard_filter": 0, "label": "Company", - "length": 0, - "no_copy": 0, "options": "Company", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 1, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "reqd": 1 }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "hero_section_based_on", "fieldtype": "Select", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, "label": "Hero Section Based On", - "length": 0, - "no_copy": 0, - "options": "Default\nSlideshow\nHomepage Section", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "options": "Default\nSlideshow\nHomepage Section" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "column_break_2", - "fieldtype": "Column Break", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "fieldtype": "Column Break" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "depends_on": "", "fieldname": "title", "fieldtype": "Data", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Title", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "label": "Title" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "depends_on": "", "fieldname": "section_break_4", "fieldtype": "Section Break", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Hero Section", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "label": "Hero Section" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "depends_on": "eval:doc.hero_section_based_on === 'Default'", "description": "Company Tagline for website homepage", "fieldname": "tag_line", "fieldtype": "Data", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, "in_list_view": 1, - "in_standard_filter": 0, "label": "Tag Line", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 1, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "reqd": 1 }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "depends_on": "eval:doc.hero_section_based_on === 'Default'", "description": "Company Description for website homepage", "fieldname": "description", "fieldtype": "Text", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, "in_list_view": 1, - "in_standard_filter": 0, "label": "Description", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 1, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "reqd": 1 }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "depends_on": "eval:doc.hero_section_based_on === 'Default'", "fieldname": "hero_image", "fieldtype": "Attach Image", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Hero Image", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "label": "Hero Image" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "depends_on": "eval:doc.hero_section_based_on === 'Slideshow'", - "description": "", "fieldname": "slideshow", "fieldtype": "Link", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, "label": "Homepage Slideshow", - "length": 0, - "no_copy": 0, - "options": "Website Slideshow", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "options": "Website Slideshow" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "depends_on": "eval:doc.hero_section_based_on === 'Homepage Section'", "fieldname": "hero_section", "fieldtype": "Link", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, "label": "Homepage Section", - "length": 0, - "no_copy": 0, - "options": "Homepage Section", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "options": "Homepage Section" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "depends_on": "", "fieldname": "products_section", "fieldtype": "Section Break", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Products", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "label": "Products" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "default": "/products", + "default": "/all-products", "fieldname": "products_url", "fieldtype": "Data", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "URL for \"All Products\"", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "label": "URL for \"All Products\"" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "description": "Products to be shown on website homepage", "fieldname": "products", "fieldtype": "Table", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, "label": "Products", - "length": 0, - "no_copy": 0, "options": "Homepage Featured Product", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0, "width": "40px" } ], - "has_web_view": 0, - "hide_heading": 0, - "hide_toolbar": 0, - "idx": 0, - "image_view": 0, - "in_create": 0, - "is_submittable": 0, "issingle": 1, - "istable": 0, - "max_attachments": 0, - "modified": "2019-03-02 23:12:59.676202", + "links": [], + "modified": "2021-02-18 13:29:29.531639", "modified_by": "Administrator", "module": "Portal", "name": "Homepage", - "name_case": "", "owner": "Administrator", "permissions": [ { - "amend": 0, - "cancel": 0, "create": 1, "delete": 1, "email": 1, - "export": 0, - "if_owner": 0, - "import": 0, - "permlevel": 0, "print": 1, "read": 1, - "report": 0, "role": "System Manager", - "set_user_permissions": 0, "share": 1, - "submit": 0, "write": 1 }, { - "amend": 0, - "cancel": 0, "create": 1, "delete": 1, "email": 1, - "export": 0, - "if_owner": 0, - "import": 0, - "permlevel": 0, "print": 1, "read": 1, - "report": 0, "role": "Administrator", - "set_user_permissions": 0, "share": 1, - "submit": 0, "write": 1 } ], - "quick_entry": 0, - "read_only": 0, - "read_only_onload": 0, - "show_name_in_global_search": 0, "sort_field": "modified", "sort_order": "DESC", "title_field": "company", - "track_changes": 1, - "track_seen": 0, - "track_views": 0 + "track_changes": 1 } \ No newline at end of file diff --git a/erpnext/portal/doctype/homepage/homepage.py b/erpnext/portal/doctype/homepage/homepage.py index 7eeaf4b80a..4477011817 100644 --- a/erpnext/portal/doctype/homepage/homepage.py +++ b/erpnext/portal/doctype/homepage/homepage.py @@ -17,7 +17,7 @@ class Homepage(Document): def setup_items(self): for d in frappe.get_all('Item', fields=['name', 'item_name', 'description', 'image'], - filters={'show_in_website': 1}, limit=3): + filters={'published_in_website': 1}, limit=3): doc = frappe.get_doc('Item', d.name) if not doc.route: diff --git a/erpnext/portal/doctype/homepage_featured_product/homepage_featured_product.json b/erpnext/portal/doctype/homepage_featured_product/homepage_featured_product.json index 01c32efec9..63789e35b5 100644 --- a/erpnext/portal/doctype/homepage_featured_product/homepage_featured_product.json +++ b/erpnext/portal/doctype/homepage_featured_product/homepage_featured_product.json @@ -25,10 +25,10 @@ "fieldtype": "Link", "in_filter": 1, "in_list_view": 1, - "label": "Item Code", + "label": "Item", "oldfieldname": "item_code", "oldfieldtype": "Link", - "options": "Item", + "options": "Website Item", "print_width": "150px", "reqd": 1, "search_index": 1, @@ -63,7 +63,7 @@ "collapsible": 1, "fieldname": "section_break_5", "fieldtype": "Section Break", - "label": "Description" + "label": "Details" }, { "fetch_from": "item_code.web_long_description", @@ -89,12 +89,14 @@ "label": "Image" }, { + "fetch_from": "item_code.thumbnail", "fieldname": "thumbnail", "fieldtype": "Attach Image", "hidden": 1, "label": "Thumbnail" }, { + "fetch_from": "item_code.route", "fieldname": "route", "fieldtype": "Small Text", "label": "route", @@ -104,7 +106,7 @@ "index_web_pages_for_search": 1, "istable": 1, "links": [], - "modified": "2020-08-25 15:27:49.573537", + "modified": "2021-02-18 13:05:50.669311", "modified_by": "Administrator", "module": "Portal", "name": "Homepage Featured Product", diff --git a/erpnext/portal/doctype/website_attribute/website_attribute.json b/erpnext/portal/doctype/website_attribute/website_attribute.json index 2874dc432c..eed33ec10e 100644 --- a/erpnext/portal/doctype/website_attribute/website_attribute.json +++ b/erpnext/portal/doctype/website_attribute/website_attribute.json @@ -1,76 +1,32 @@ { - "allow_copy": 0, - "allow_events_in_timeline": 0, - "allow_guest_to_view": 0, - "allow_import": 0, - "allow_rename": 0, - "beta": 0, - "creation": "2019-01-01 13:04:54.479079", - "custom": 0, - "docstatus": 0, - "doctype": "DocType", - "document_type": "", - "editable_grid": 1, - "engine": "InnoDB", + "actions": [], + "creation": "2019-01-01 13:04:54.479079", + "doctype": "DocType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "attribute" + ], "fields": [ { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "attribute", - "fieldtype": "Link", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 1, - "in_standard_filter": 0, - "label": "Attribute", - "length": 0, - "no_copy": 0, - "options": "Item Attribute", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 1, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "fieldname": "attribute", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Attribute", + "options": "Item Attribute", + "reqd": 1 } - ], - "has_web_view": 0, - "hide_heading": 0, - "hide_toolbar": 0, - "idx": 0, - "image_view": 0, - "in_create": 0, - "is_submittable": 0, - "issingle": 0, - "istable": 1, - "max_attachments": 0, - "modified": "2019-01-01 13:04:59.715572", - "modified_by": "Administrator", - "module": "Portal", - "name": "Website Attribute", - "name_case": "", - "owner": "Administrator", - "permissions": [], - "quick_entry": 1, - "read_only": 0, - "read_only_onload": 0, - "show_name_in_global_search": 0, - "sort_field": "modified", - "sort_order": "DESC", - "track_changes": 1, - "track_seen": 0, - "track_views": 0 + ], + "istable": 1, + "links": [], + "modified": "2021-02-18 13:18:57.810536", + "modified_by": "Administrator", + "module": "Portal", + "name": "Website Attribute", + "owner": "Administrator", + "permissions": [], + "quick_entry": 1, + "sort_field": "modified", + "sort_order": "DESC", + "track_changes": 1 } \ No newline at end of file diff --git a/erpnext/selling/doctype/customer/customer.py b/erpnext/selling/doctype/customer/customer.py index 7adf2cd909..3f60801c6e 100644 --- a/erpnext/selling/doctype/customer/customer.py +++ b/erpnext/selling/doctype/customer/customer.py @@ -294,30 +294,6 @@ class Customer(TransactionBase): .format(frappe.bold(self.customer_name)) ) - def create_onboarding_docs(self, args): - defaults = frappe.defaults.get_defaults() - company = defaults.get('company') or \ - frappe.db.get_single_value('Global Defaults', 'default_company') - - for i in range(1, args.get('max_count')): - customer = args.get('customer_name_' + str(i)) - if customer: - try: - doc = frappe.get_doc({ - 'doctype': self.doctype, - 'customer_name': customer, - 'customer_type': 'Company', - 'customer_group': _('Commercial'), - 'territory': defaults.get('country'), - 'company': company - }).insert() - - if args.get('customer_email_' + str(i)): - create_contact(customer, self.doctype, - doc.name, args.get("customer_email_" + str(i))) - except frappe.NameError: - pass - def create_contact(contact, party_type, party, email): """Create contact based on given contact name""" contact = contact.split(' ') diff --git a/erpnext/selling/onboarding_slide/add_a_few_customers/add_a_few_customers.json b/erpnext/selling/onboarding_slide/add_a_few_customers/add_a_few_customers.json deleted file mode 100644 index 92d00bcb38..0000000000 --- a/erpnext/selling/onboarding_slide/add_a_few_customers/add_a_few_customers.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "add_more_button": 1, - "app": "ERPNext", - "creation": "2019-11-15 14:44:10.065014", - "docstatus": 0, - "doctype": "Onboarding Slide", - "domains": [], - "help_links": [ - { - "label": "Learn More", - "video_id": "zsrrVDk6VBs" - } - ], - "idx": 0, - "image_src": "", - "is_completed": 0, - "max_count": 3, - "modified": "2019-12-09 17:54:01.686006", - "modified_by": "Administrator", - "name": "Add A Few Customers", - "owner": "Administrator", - "ref_doctype": "Customer", - "slide_desc": "", - "slide_fields": [ - { - "align": "", - "fieldname": "customer_name", - "fieldtype": "Data", - "label": "Customer Name", - "placeholder": "", - "reqd": 1 - }, - { - "align": "", - "fieldtype": "Column Break", - "reqd": 0 - }, - { - "align": "", - "fieldname": "customer_email", - "fieldtype": "Data", - "label": "Email ID", - "reqd": 1 - } - ], - "slide_order": 40, - "slide_title": "Add A Few Customers", - "slide_type": "Create" -} \ No newline at end of file diff --git a/erpnext/setup/doctype/item_group/item_group.py b/erpnext/setup/doctype/item_group/item_group.py index 3965d82751..d19e1897fc 100644 --- a/erpnext/setup/doctype/item_group/item_group.py +++ b/erpnext/setup/doctype/item_group/item_group.py @@ -138,85 +138,6 @@ class ItemGroup(NestedSet, WebsiteGenerator): from erpnext.stock.doctype.item.item import validate_item_default_company_links validate_item_default_company_links(self.item_group_defaults) -@frappe.whitelist(allow_guest=True) -def get_product_list_for_group(product_group=None, start=0, limit=10, search=None): - if product_group: - item_group = frappe.get_cached_doc('Item Group', product_group) - if item_group.is_group: - # return child item groups if the type is of "Is Group" - return get_child_groups_for_list_in_html(item_group, start, limit, search) - - child_groups = ", ".join(frappe.db.escape(i[0]) for i in get_child_groups(product_group)) - - # base query - query = """select I.name, I.item_name, I.item_code, I.route, I.image, I.website_image, I.thumbnail, I.item_group, - I.description, I.web_long_description as website_description, I.is_stock_item, - case when (S.actual_qty - S.reserved_qty) > 0 then 1 else 0 end as in_stock, I.website_warehouse, - I.has_batch_no - from `tabItem` I - left join tabBin S on I.item_code = S.item_code and I.website_warehouse = S.warehouse - where I.show_in_website = 1 - and I.disabled = 0 - and (I.end_of_life is null or I.end_of_life='0000-00-00' or I.end_of_life > %(today)s) - and (I.variant_of = '' or I.variant_of is null) - and (I.item_group in ({child_groups}) - or I.name in (select parent from `tabWebsite Item Group` where item_group in ({child_groups}))) - """.format(child_groups=child_groups) - # search term condition - if search: - query += """ and (I.web_long_description like %(search)s - or I.item_name like %(search)s - or I.name like %(search)s)""" - search = "%" + cstr(search) + "%" - - query += """order by I.weightage desc, in_stock desc, I.modified desc limit %s, %s""" % (cint(start), cint(limit)) - - data = frappe.db.sql(query, {"product_group": product_group,"search": search, "today": nowdate()}, as_dict=1) - data = adjust_qty_for_expired_items(data) - - if cint(frappe.db.get_single_value("E Commerce Settings", "enabled")): - for item in data: - set_product_info_for_website(item) - - return data - -def get_child_groups_for_list_in_html(item_group, start, limit, search): - search_filters = None - if search_filters: - search_filters = [ - dict(name = ('like', '%{}%'.format(search))), - dict(description = ('like', '%{}%'.format(search))) - ] - data = frappe.db.get_all('Item Group', - fields = ['name', 'route', 'description', 'image'], - filters = dict( - show_in_website = 1, - parent_item_group = item_group.name, - lft = ('>', item_group.lft), - rgt = ('<', item_group.rgt), - ), - or_filters = search_filters, - order_by = 'weightage desc, name asc', - start = start, - limit = limit - ) - - return data - -def adjust_qty_for_expired_items(data): - adjusted_data = [] - - for item in data: - if item.get('has_batch_no') and item.get('website_warehouse'): - stock_qty_dict = get_qty_in_stock( - item.get('name'), 'website_warehouse', item.get('website_warehouse')) - qty = stock_qty_dict.stock_qty[0][0] if stock_qty_dict.stock_qty else 0 - item['in_stock'] = 1 if qty else 0 - adjusted_data.append(item) - - return adjusted_data - - def get_child_groups(item_group_name): item_group = frappe.get_doc("Item Group", item_group_name) return frappe.db.sql("""select name @@ -245,14 +166,6 @@ def get_item_for_list_in_html(context): return frappe.get_template(products_template).render(context) -def get_group_item_count(item_group): - child_groups = ", ".join('"' + i[0] + '"' for i in get_child_groups(item_group)) - return frappe.db.sql("""select count(*) from `tabItem` - where docstatus = 0 and show_in_website = 1 - and (item_group in (%s) - or name in (select parent from `tabWebsite Item Group` - where item_group in (%s))) """ % (child_groups, child_groups))[0][0] - def get_parent_item_groups(item_group_name): base_parents = [ diff --git a/erpnext/setup/onboarding_slide/welcome_back_to_erpnext!/welcome_back_to_erpnext!.json b/erpnext/setup/onboarding_slide/welcome_back_to_erpnext!/welcome_back_to_erpnext!.json deleted file mode 100644 index f00dc947d2..0000000000 --- a/erpnext/setup/onboarding_slide/welcome_back_to_erpnext!/welcome_back_to_erpnext!.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "add_more_button": 0, - "app": "ERPNext", - "creation": "2019-12-04 19:21:39.995776", - "docstatus": 0, - "doctype": "Onboarding Slide", - "domains": [], - "help_links": [], - "idx": 0, - "image_src": "", - "is_completed": 0, - "max_count": 3, - "modified": "2019-12-09 17:53:53.849953", - "modified_by": "Administrator", - "name": "Welcome back to ERPNext!", - "owner": "Administrator", - "slide_desc": "

Let's continue where you left from!

", - "slide_fields": [], - "slide_module": "Setup", - "slide_order": 0, - "slide_title": "Welcome back to ERPNext!", - "slide_type": "Continue" -} \ No newline at end of file diff --git a/erpnext/setup/onboarding_slide/welcome_to_erpnext!/welcome_to_erpnext!.json b/erpnext/setup/onboarding_slide/welcome_to_erpnext!/welcome_to_erpnext!.json deleted file mode 100644 index 37eb67b1d7..0000000000 --- a/erpnext/setup/onboarding_slide/welcome_to_erpnext!/welcome_to_erpnext!.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "add_more_button": 0, - "app": "ERPNext", - "creation": "2019-11-26 17:01:26.671859", - "docstatus": 0, - "doctype": "Onboarding Slide", - "domains": [], - "help_links": [], - "idx": 0, - "image_src": "", - "is_completed": 0, - "max_count": 0, - "modified": "2019-12-22 21:26:28.414597", - "modified_by": "Administrator", - "name": "Welcome to ERPNext!", - "owner": "Administrator", - "slide_desc": "
Setting up an ERP can be overwhelming. But don't worry, we have got your back! This wizard will help you onboard to ERPNext in a short time!
", - "slide_fields": [], - "slide_module": "Setup", - "slide_order": 1, - "slide_title": "Welcome to ERPNext!", - "slide_type": "Information" -} \ No newline at end of file diff --git a/erpnext/shopping_cart/filters.py b/erpnext/shopping_cart/filters.py index ed32db2105..4fe346b659 100644 --- a/erpnext/shopping_cart/filters.py +++ b/erpnext/shopping_cart/filters.py @@ -48,8 +48,7 @@ class ProductFiltersBuilder: values = [d.name for d in frappe.get_all(doctype, filters)] # Remove None - if None in values: - values.remove(None) + if None in values: values.remove(None) if values: filter_data.append([df, values]) diff --git a/erpnext/shopping_cart/search.py b/erpnext/shopping_cart/search.py index 5d2de78f7c..30656befd6 100644 --- a/erpnext/shopping_cart/search.py +++ b/erpnext/shopping_cart/search.py @@ -111,7 +111,7 @@ class ProductSearch(FullTextSearch): ) def get_all_published_items(): - return frappe.get_all("Item", filters={"variant_of": "", "show_in_website": 1},pluck="name") + return frappe.get_all("Website Item", filters={"variant_of": "", "published": 1}, pluck="item_code") def update_index_for_path(path): search = ProductSearch(INDEX_NAME) diff --git a/erpnext/stock/doctype/item/item.js b/erpnext/stock/doctype/item/item.js index fb2ccef48f..b3edd9fc30 100644 --- a/erpnext/stock/doctype/item/item.js +++ b/erpnext/stock/doctype/item/item.js @@ -91,7 +91,7 @@ frappe.ui.form.on("Item", { erpnext.toggle_naming_series(); } - if(!frm.doc.published_in_website) { + if (!frm.doc.published_in_website) { frm.add_custom_button(__("Publish in Website"), function() { frappe.call({ method: "erpnext.e_commerce.doctype.website_item.website_item.make_website_item", @@ -102,8 +102,8 @@ frappe.ui.form.on("Item", { frappe.msgprint({ message: __("Website Item {0} has been created.", [repl('%(item)s', { - item_encoded: encodeURIComponent(result.message[0]), - item: result.message[1] + item_encoded: encodeURIComponent(result.message[0]), + item: result.message[1] })] ), title: __("Published"), @@ -205,25 +205,8 @@ frappe.ui.form.on("Item", { } }, - copy_from_item_group: function(frm) { - return frm.call({ - doc: frm.doc, - method: "copy_specification_from_item_group" - }); - }, - has_variants: function(frm) { erpnext.item.toggle_attributes(frm); - }, - - show_in_website: function(frm) { - if (frm.doc.default_warehouse && !frm.doc.website_warehouse){ - frm.set_value("website_warehouse", frm.doc.default_warehouse); - } - }, - - set_meta_tags(frm) { - frappe.utils.set_meta_tag(frm.doc.route); } }); diff --git a/erpnext/stock/doctype/item/item.json b/erpnext/stock/doctype/item/item.json index 39cc9c75e2..82452b6543 100644 --- a/erpnext/stock/doctype/item/item.json +++ b/erpnext/stock/doctype/item/item.json @@ -116,24 +116,6 @@ "customer_code", "default_item_manufacturer", "default_manufacturer_part_no", - "website_section", - "published_in_website", - "show_in_website", - "show_variant_in_website", - "route", - "weightage", - "slideshow", - "website_image", - "website_image_alt", - "cb72", - "website_warehouse", - "website_item_groups", - "set_meta_tags", - "sb72", - "copy_from_item_group", - "website_specifications", - "web_long_description", - "website_content", "total_projected_qty", "hub_publishing_sb", "publish_in_hub", @@ -869,119 +851,6 @@ "no_copy": 1, "print_hide": 1 }, - { - "collapsible": 1, - "depends_on": "eval:!doc.is_fixed_asset", - "fieldname": "website_section", - "fieldtype": "Section Break", - "label": "Website", - "options": "fa fa-globe" - }, - { - "default": "0", - "depends_on": "eval:!doc.variant_of", - "fieldname": "show_in_website", - "fieldtype": "Check", - "label": "Show in Website", - "search_index": 1 - }, - { - "default": "0", - "depends_on": "variant_of", - "fieldname": "show_variant_in_website", - "fieldtype": "Check", - "label": "Show in Website (Variant)", - "search_index": 1 - }, - { - "depends_on": "eval: doc.show_in_website || doc.show_variant_in_website", - "fieldname": "route", - "fieldtype": "Small Text", - "label": "Route", - "no_copy": 1 - }, - { - "depends_on": "eval: doc.show_in_website || doc.show_variant_in_website", - "description": "Items with higher weightage will be shown higher", - "fieldname": "weightage", - "fieldtype": "Int", - "label": "Weightage" - }, - { - "depends_on": "eval: doc.show_in_website || doc.show_variant_in_website", - "description": "Show a slideshow at the top of the page", - "fieldname": "slideshow", - "fieldtype": "Link", - "label": "Slideshow", - "options": "Website Slideshow" - }, - { - "depends_on": "eval: doc.show_in_website || doc.show_variant_in_website", - "description": "Item Image (if not slideshow)", - "fieldname": "website_image", - "fieldtype": "Attach", - "label": "Website Image" - }, - { - "fieldname": "cb72", - "fieldtype": "Column Break" - }, - { - "depends_on": "eval: doc.show_in_website || doc.show_variant_in_website", - "description": "Show \"In Stock\" or \"Not in Stock\" based on stock available in this warehouse.", - "fieldname": "website_warehouse", - "fieldtype": "Link", - "ignore_user_permissions": 1, - "label": "Website Warehouse", - "options": "Warehouse" - }, - { - "depends_on": "eval: doc.show_in_website || doc.show_variant_in_website", - "description": "List this Item in multiple groups on the website.", - "fieldname": "website_item_groups", - "fieldtype": "Table", - "label": "Website Item Groups", - "options": "Website Item Group" - }, - { - "depends_on": "eval: doc.show_in_website || doc.show_variant_in_website", - "fieldname": "set_meta_tags", - "fieldtype": "Button", - "label": "Set Meta Tags" - }, - { - "collapsible": 1, - "collapsible_depends_on": "website_specifications", - "depends_on": "eval: doc.show_in_website || doc.show_variant_in_website", - "fieldname": "sb72", - "fieldtype": "Section Break", - "label": "Website Specifications" - }, - { - "depends_on": "eval: doc.show_in_website || doc.show_variant_in_website", - "fieldname": "copy_from_item_group", - "fieldtype": "Button", - "label": "Copy From Item Group" - }, - { - "depends_on": "eval: doc.show_in_website || doc.show_variant_in_website", - "fieldname": "website_specifications", - "fieldtype": "Table", - "label": "Website Specifications", - "options": "Item Website Specification" - }, - { - "depends_on": "eval: doc.show_in_website || doc.show_variant_in_website", - "fieldname": "web_long_description", - "fieldtype": "Text Editor", - "label": "Website Description" - }, - { - "description": "You can use any valid Bootstrap 4 markup in this field. It will be shown on your Item Page.", - "fieldname": "website_content", - "fieldtype": "HTML Editor", - "label": "Website Content" - }, { "fieldname": "total_projected_qty", "fieldtype": "Float", @@ -1057,24 +926,8 @@ "fieldtype": "Data", "label": "Default Manufacturer Part No", "read_only": 1 - }, - { - "depends_on": "eval: doc.show_in_website || doc.show_variant_in_website", - "fieldname": "website_image_alt", - "fieldtype": "Data", - "label": "Image Description" - }, - { - "default": "0", - "fieldname": "published_in_website", - "fieldtype": "Check", - "label": "Published in Website", - "no_copy": 1, - "read_only": 1, - "search_index": 1 } ], - "has_web_view": 1, "icon": "fa fa-tag", "idx": 2, "image_field": "image", diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py index 2de4689f27..59bb7a0098 100644 --- a/erpnext/stock/doctype/item/item.py +++ b/erpnext/stock/doctype/item/item.py @@ -22,6 +22,7 @@ from frappe.utils import ( ) from frappe.utils.html_utils import clean_html from frappe.website.utils import clear_cache +from frappe.model.document import Document from frappe.website.website_generator import WebsiteGenerator import erpnext @@ -51,17 +52,8 @@ class InvalidBarcode(frappe.ValidationError): pass -class Item(WebsiteGenerator): - website = frappe._dict( - page_title_field="item_name", - condition_field="show_in_website", - template="templates/generators/item/item.html", - no_cache=1 - ) - +class Item(Document): def onload(self): - super(Item, self).onload() - self.set_onload('stock_exists', self.stock_ledger_created()) self.set_asset_naming_series() @@ -102,8 +94,6 @@ class Item(WebsiteGenerator): self.set_opening_stock() def validate(self): - super(Item, self).validate() - if not self.item_name: self.item_name = self.item_code @@ -143,9 +133,6 @@ class Item(WebsiteGenerator): if not self.is_new(): self.old_item_group = frappe.db.get_value(self.doctype, self.name, "item_group") - self.old_website_item_groups = frappe.db.sql_list("""select item_group - from `tabWebsite Item Group` - where parentfield='website_item_groups' and parenttype='Item' and parent=%s""", self.name) def on_update(self): invalidate_cache_for_item(self) @@ -485,16 +472,6 @@ class Item(WebsiteGenerator): frappe.db.set_value("Stock Settings", None, "allow_negative_stock", existing_allow_negative_stock) frappe.db.auto_commit_on_many_writes = 0 - @frappe.whitelist() - def copy_specification_from_item_group(self): - self.set("website_specifications", []) - if self.item_group: - for label, desc in frappe.db.get_values("Item Website Specification", - {"parent": self.item_group}, ["label", "description"]): - row = self.append("website_specifications") - row.label = label - row.description = desc - def update_bom_item_desc(self): if self.is_new(): return @@ -768,46 +745,6 @@ class Item(WebsiteGenerator): if not enabled: frappe.msgprint(msg=_("You have to enable auto re-order in Stock Settings to maintain re-order levels."), title=_("Enable Auto Re-Order"), indicator="orange") - def create_onboarding_docs(self, args): - company = frappe.defaults.get_defaults().get('company') or \ - frappe.db.get_single_value('Global Defaults', 'default_company') - - for i in range(1, args.get('max_count')): - item = args.get('item_' + str(i)) - if item: - default_warehouse = '' - default_warehouse = frappe.db.get_value('Warehouse', filters={ - 'warehouse_name': _('Finished Goods'), - 'company': company - }) - - try: - frappe.get_doc({ - 'doctype': self.doctype, - 'item_code': item, - 'item_name': item, - 'description': item, - 'is_sales_item': 1, - 'is_purchase_item': 1, - 'is_stock_item': 1, - 'item_group': _('Products'), - 'stock_uom': _(args.get('item_uom_' + str(i))), - 'item_defaults': [{ - 'default_warehouse': default_warehouse, - 'company': company - }] - }).insert() - - except frappe.NameError: - pass - else: - if args.get('item_price_' + str(i)): - item_price = flt(args.get('item_price_' + str(i))) - - price_list_name = frappe.db.get_value('Price List', {'selling': 1}) - make_item_price(item, price_list_name, item_price) - price_list_name = frappe.db.get_value('Price List', {'buying': 1}) - make_item_price(item, price_list_name, item_price) def make_item_price(item, price_list_name, item_price): frappe.get_doc({ @@ -924,12 +861,6 @@ def get_last_purchase_details(item_code, doc_name=None, conversion_rate=1.0): def invalidate_cache_for_item(doc): invalidate_cache_for(doc, doc.item_group) - website_item_groups = list(set((doc.get("old_website_item_groups") or []) - + [d.item_group for d in doc.get({"doctype": "Website Item Group"}) if d.item_group])) - - for item_group in website_item_groups: - invalidate_cache_for(doc, item_group) - if doc.get("old_item_group") and doc.get("old_item_group") != doc.item_group: invalidate_cache_for(doc, doc.old_item_group) @@ -940,9 +871,10 @@ def invalidate_item_variants_cache_for_website(doc): from erpnext.portal.product_configurator.item_variants_cache import ItemVariantsCacheManager item_code = None - if doc.has_variants and doc.show_in_website: - item_code = doc.name - elif doc.variant_of and frappe.db.get_value('Item', doc.variant_of, 'show_in_website'): + is_web_item = doc.get("published_in_website") or doc.get("published") + if doc.has_variants and is_web_item: + item_code = doc.item_code + elif doc.variant_of and frappe.db.get_value('Item', doc.variant_of, 'published_in_website'): item_code = doc.variant_of if item_code: diff --git a/erpnext/stock/doctype/item/test_records.json b/erpnext/stock/doctype/item/test_records.json index 6cec85288f..91c77d5152 100644 --- a/erpnext/stock/doctype/item/test_records.json +++ b/erpnext/stock/doctype/item/test_records.json @@ -40,9 +40,7 @@ "conversion_factor": 10.0 } ], - "stock_uom": "_Test UOM", - "show_in_website": 1, - "website_warehouse": "_Test Warehouse - _TC" + "stock_uom": "_Test UOM" }, { "description": "_Test Item 2", @@ -56,8 +54,6 @@ "item_group": "_Test Item Group", "item_name": "_Test Item 2", "stock_uom": "_Test UOM", - "show_in_website": 1, - "website_warehouse": "_Test Warehouse - _TC", "gst_hsn_code": "999800", "opening_stock": 10, "valuation_rate": 100, @@ -311,8 +307,7 @@ "warehouse_reorder_level": 20, "warehouse_reorder_qty": 20 } - ], - "show_in_website": 1 + ] }, { "description": "_Test Item 1", @@ -344,9 +339,7 @@ "warehouse_reorder_qty": 20 } ], - "stock_uom": "_Test UOM", - "show_in_website": 1, - "website_warehouse": "_Test Warehouse Group-C1 - _TC" + "stock_uom": "_Test UOM" }, { "description": "_Test Item With Item Tax Template", diff --git a/erpnext/stock/doctype/item_variant_settings/item_variant_settings.js b/erpnext/stock/doctype/item_variant_settings/item_variant_settings.js index 488920aadb..5e1f7d5322 100644 --- a/erpnext/stock/doctype/item_variant_settings/item_variant_settings.js +++ b/erpnext/stock/doctype/item_variant_settings/item_variant_settings.js @@ -7,9 +7,8 @@ frappe.ui.form.on('Item Variant Settings', { const existing_fields = frm.doc.fields.map(row => row.field_name); const exclude_fields = [...existing_fields, "naming_series", "item_code", "item_name", - "show_in_website", "show_variant_in_website", "standard_rate", "opening_stock", "image", - "variant_of", "valuation_rate", "barcodes", "website_image", "thumbnail", - "website_specifiations", "web_long_description", "has_variants", "attributes"]; + "published_in_website", "standard_rate", "opening_stock", "image", + "variant_of", "valuation_rate", "barcodes", "has_variants", "attributes"]; const exclude_field_types = ['HTML', 'Section Break', 'Column Break', 'Button', 'Read Only']; diff --git a/erpnext/stock/doctype/item_variant_settings/item_variant_settings.py b/erpnext/stock/doctype/item_variant_settings/item_variant_settings.py index cb6626fd17..bd9e9b9d55 100644 --- a/erpnext/stock/doctype/item_variant_settings/item_variant_settings.py +++ b/erpnext/stock/doctype/item_variant_settings/item_variant_settings.py @@ -1,9 +1,7 @@ # -*- coding: utf-8 -*- -# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors +# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors # For license information, please see license.txt -from __future__ import unicode_literals - import frappe from frappe import _ from frappe.model.document import Document @@ -15,7 +13,7 @@ class ItemVariantSettings(Document): def set_default_fields(self): self.fields = [] fields = frappe.get_meta('Item').fields - exclude_fields = {"naming_series", "item_code", "item_name", "show_in_website", + exclude_fields = {"naming_series", "item_code", "item_name", "published_in_website", "show_variant_in_website", "standard_rate", "opening_stock", "image", "description", "variant_of", "valuation_rate", "description", "barcodes", "website_image", "thumbnail", "website_specifiations", "web_long_description", diff --git a/erpnext/stock/onboarding_slide/add_a_few_products_you_buy_or_sell/add_a_few_products_you_buy_or_sell.json b/erpnext/stock/onboarding_slide/add_a_few_products_you_buy_or_sell/add_a_few_products_you_buy_or_sell.json deleted file mode 100644 index 5ee316786c..0000000000 --- a/erpnext/stock/onboarding_slide/add_a_few_products_you_buy_or_sell/add_a_few_products_you_buy_or_sell.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "add_more_button": 1, - "app": "ERPNext", - "creation": "2019-11-15 14:41:12.007359", - "docstatus": 0, - "doctype": "Onboarding Slide", - "domains": [], - "help_links": [], - "idx": 0, - "image_src": "", - "is_completed": 0, - "max_count": 3, - "modified": "2019-12-09 17:54:09.602885", - "modified_by": "Administrator", - "name": "Add A Few Products You Buy Or Sell", - "owner": "Administrator", - "ref_doctype": "Item", - "slide_desc": "", - "slide_fields": [ - { - "align": "", - "fieldname": "item", - "fieldtype": "Data", - "label": "Item", - "placeholder": "Product Name", - "reqd": 1 - }, - { - "align": "", - "fieldname": "item_price", - "fieldtype": "Currency", - "label": "Item Price", - "reqd": 1 - }, - { - "align": "", - "fieldtype": "Column Break", - "reqd": 0 - }, - { - "align": "", - "fieldname": "uom", - "fieldtype": "Link", - "label": "UOM", - "options": "UOM", - "reqd": 1 - } - ], - "slide_order": 30, - "slide_title": "Add A Few Products You Buy Or Sell", - "slide_type": "Create" -} \ No newline at end of file