diff --git a/erpnext/e_commerce/doctype/website_item/website_item.py b/erpnext/e_commerce/doctype/website_item/website_item.py
index dad9b9bd3694..6ff697ced924 100644
--- a/erpnext/e_commerce/doctype/website_item/website_item.py
+++ b/erpnext/e_commerce/doctype/website_item/website_item.py
@@ -33,6 +33,15 @@ class WebsiteItem(WebsiteGenerator):
no_cache=1
)
+ def autoname(self):
+ # use naming series to accomodate items with same name (different item code)
+ from erpnext.setup.doctype.naming_series.naming_series import get_default_naming_series
+ from frappe.model.naming import make_autoname
+
+ naming_series = get_default_naming_series("Website Item")
+ if not self.name and naming_series:
+ self.name = make_autoname(naming_series, doc=self)
+
def onload(self):
super(WebsiteItem, self).onload()
@@ -137,7 +146,7 @@ def validate_website_image(self):
def make_thumbnail(self):
"""Make a thumbnail of `website_image`"""
- if frappe.flags.in_import or frappe.flags.in_migrate:
+ if frappe.flags.in_import:
return
import requests.exceptions
@@ -210,7 +219,7 @@ def get_context(self, context):
self.get_product_details_section(context)
- if settings.enable_reviews:
+ if settings.get("enable_reviews"):
reviews_data = get_item_reviews(self.name)
context.update(reviews_data)
context.reviews = context.reviews[:4]
diff --git a/erpnext/e_commerce/shopping_cart/product_info.py b/erpnext/e_commerce/shopping_cart/product_info.py
index 5e3bdc5c3621..28e05bb940b8 100644
--- a/erpnext/e_commerce/shopping_cart/product_info.py
+++ b/erpnext/e_commerce/shopping_cart/product_info.py
@@ -23,7 +23,11 @@ def get_product_info_for_website(item_code, skip_quotation_creation=False):
cart_settings = get_shopping_cart_settings()
if not cart_settings.enabled:
- return frappe._dict()
+ # return settings even if cart is disabled
+ return frappe._dict({
+ "product_info": {},
+ "cart_settings": cart_settings
+ })
cart_quotation = frappe._dict()
if not skip_quotation_creation:
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index 84531455d5cc..05af88888f78 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -309,7 +309,7 @@ erpnext.patches.v13_0.reset_clearance_date_for_intracompany_payment_entries
erpnext.patches.v13_0.custom_fields_for_taxjar_integration
erpnext.patches.v13_0.set_operation_time_based_on_operating_cost
erpnext.patches.v13_0.validate_options_for_data_field
-erpnext.patches.v13_0.create_website_items
+erpnext.patches.v13_0.create_website_items #30-09-2021
erpnext.patches.v13_0.populate_e_commerce_settings
erpnext.patches.v13_0.make_homepage_products_website_items
erpnext.patches.v13_0.update_dates_in_tax_withholding_category
diff --git a/erpnext/patches/v13_0/create_website_items.py b/erpnext/patches/v13_0/create_website_items.py
index a63dc897f44d..5c245ca29fca 100644
--- a/erpnext/patches/v13_0/create_website_items.py
+++ b/erpnext/patches/v13_0/create_website_items.py
@@ -46,28 +46,32 @@ def execute():
count = 0
for item in items:
if frappe.db.exists("Website Item", {"item_code": item.item_code}):
- continue
+ # if website item already exists check for empty thumbnail
+ web_item_doc = frappe.get_doc("Website Item", {"item_code": item.item_code})
+ if web_item_doc.website_image and not web_item_doc.thumbnail:
+ web_item_doc.make_thumbnail()
+ web_item_doc.save()
+ else:
+ # else make new website item from item (publish item)
+ website_item = make_website_item(item, save=False)
+ website_item.ranking = item.get("weightage")
+ for field in web_fields_to_map:
+ website_item.update({field: item.get(field)})
+ website_item.save()
- # make website item from item (publish item)
- website_item = make_website_item(item, save=False)
- website_item.ranking = item.get("weightage")
- for field in web_fields_to_map:
- website_item.update({field: item.get(field)})
- website_item.save()
-
- # move Website Item Group & Website Specification table to Website Item
- for doctype in ("Website Item Group", "Item Website Specification"):
- web_item, item_code = website_item.name, item.item_code
- frappe.db.sql(f"""
- Update
- `tab{doctype}`
- set
- parenttype = 'Website Item',
- parent = '{web_item}'
- where
- parenttype = 'Item'
- and parent = '{item_code}'
- """)
+ # move Website Item Group & Website Specification table to Website Item
+ for doctype in ("Website Item Group", "Item Website Specification"):
+ web_item, item_code = website_item.name, item.item_code
+ frappe.db.sql(f"""
+ Update
+ `tab{doctype}`
+ set
+ parenttype = 'Website Item',
+ parent = '{web_item}'
+ where
+ parenttype = 'Item'
+ and parent = '{item_code}'
+ """)
count += 1
if count % 20 == 0: # commit after every 20 items
diff --git a/erpnext/templates/includes/cart/cart_payment_summary.html b/erpnext/templates/includes/cart/cart_payment_summary.html
index 847d45f8ffea..b5655a237b10 100644
--- a/erpnext/templates/includes/cart/cart_payment_summary.html
+++ b/erpnext/templates/includes/cart/cart_payment_summary.html
@@ -1,51 +1,56 @@
+{% if cart_settings.enable_checkout or cart_settings.show_price_in_quotation %}
{{ _("Payment Summary") }}
+{% endif %}
+
-
-
- {% set total_items = frappe.utils.cstr(frappe.utils.flt(doc.total_qty, 0)) %}
- {{ _("Net Total (") + total_items + _(" Items)") }} |
- {{ doc.get_formatted("net_total") }} |
-
+ {% if cart_settings.enable_checkout or cart_settings.show_price_in_quotation %}
+
+
+ {% set total_items = frappe.utils.cstr(frappe.utils.flt(doc.total_qty, 0)) %}
+ {{ _("Net Total (") + total_items + _(" Items)") }} |
+ {{ doc.get_formatted("net_total") }} |
+
-
- {% for d in doc.taxes %}
- {% if d.base_tax_amount %}
-
-
- {{ d.description }}
- |
-
- {{ d.get_formatted("base_tax_amount") }}
- |
-
- {% endif %}
- {% endfor %}
-
+
+ {% for d in doc.taxes %}
+ {% if d.base_tax_amount %}
+
+
+ {{ d.description }}
+ |
+
+ {{ d.get_formatted("base_tax_amount") }}
+ |
+
+ {% endif %}
+ {% endfor %}
+
-
-
+
+
-
-
- {{ _("Grand Total") }} |
- {{ doc.get_formatted("grand_total") }} |
-
-
+
+
+ {{ _("Grand Total") }} |
+ {{ doc.get_formatted("grand_total") }} |
+
+
+ {% endif %}
{% if cart_settings.enable_checkout %}
{% endif %}
- {% if cart_settings.enable_checkout %}
-
- {% include "templates/includes/cart/cart_payment_summary.html" %}
-
- {% endif %}
+
+ {% include "templates/includes/cart/cart_payment_summary.html" %}
+
{% include "templates/includes/cart/cart_address.html" %}