Merge pull request #27757 from frappe/mergify/bp/version-13-pre-release/pr-27720

fix: Website Items with same Item name unhandled, thumbnails missing (backport #27720)
This commit is contained in:
Marica
2021-10-03 14:46:18 +05:30
committed by GitHub
6 changed files with 90 additions and 69 deletions

View File

@@ -33,6 +33,16 @@ class WebsiteItem(WebsiteGenerator):
no_cache=1 no_cache=1
) )
def autoname(self):
# use naming series to accomodate items with same name (different item code)
from frappe.model.naming import make_autoname
from erpnext.setup.doctype.naming_series.naming_series import get_default_naming_series
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): def onload(self):
super(WebsiteItem, self).onload() super(WebsiteItem, self).onload()
@@ -137,7 +147,7 @@ class WebsiteItem(WebsiteGenerator):
def make_thumbnail(self): def make_thumbnail(self):
"""Make a thumbnail of `website_image`""" """Make a thumbnail of `website_image`"""
if frappe.flags.in_import or frappe.flags.in_migrate: if frappe.flags.in_import:
return return
import requests.exceptions import requests.exceptions
@@ -210,7 +220,7 @@ class WebsiteItem(WebsiteGenerator):
self.get_product_details_section(context) self.get_product_details_section(context)
if settings.enable_reviews: if settings.get("enable_reviews"):
reviews_data = get_item_reviews(self.name) reviews_data = get_item_reviews(self.name)
context.update(reviews_data) context.update(reviews_data)
context.reviews = context.reviews[:4] context.reviews = context.reviews[:4]

View File

@@ -23,7 +23,11 @@ def get_product_info_for_website(item_code, skip_quotation_creation=False):
cart_settings = get_shopping_cart_settings() cart_settings = get_shopping_cart_settings()
if not cart_settings.enabled: 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() cart_quotation = frappe._dict()
if not skip_quotation_creation: if not skip_quotation_creation:

View File

@@ -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.custom_fields_for_taxjar_integration
erpnext.patches.v13_0.set_operation_time_based_on_operating_cost erpnext.patches.v13_0.set_operation_time_based_on_operating_cost
erpnext.patches.v13_0.validate_options_for_data_field 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.populate_e_commerce_settings
erpnext.patches.v13_0.make_homepage_products_website_items erpnext.patches.v13_0.make_homepage_products_website_items
erpnext.patches.v13_0.update_dates_in_tax_withholding_category erpnext.patches.v13_0.update_dates_in_tax_withholding_category

View File

@@ -46,9 +46,13 @@ def execute():
count = 0 count = 0
for item in items: for item in items:
if frappe.db.exists("Website Item", {"item_code": item.item_code}): 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})
# make website item from item (publish item) 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 = make_website_item(item, save=False)
website_item.ranking = item.get("weightage") website_item.ranking = item.get("weightage")
for field in web_fields_to_map: for field in web_fields_to_map:

View File

@@ -1,9 +1,13 @@
<!-- Payment --> <!-- Payment -->
{% if cart_settings.enable_checkout or cart_settings.show_price_in_quotation %}
<h6> <h6>
{{ _("Payment Summary") }} {{ _("Payment Summary") }}
</h6> </h6>
{% endif %}
<div class="card h-100"> <div class="card h-100">
<div class="card-body p-0"> <div class="card-body p-0">
{% if cart_settings.enable_checkout or cart_settings.show_price_in_quotation %}
<table class="table w-100"> <table class="table w-100">
<tr> <tr>
{% set total_items = frappe.utils.cstr(frappe.utils.flt(doc.total_qty, 0)) %} {% set total_items = frappe.utils.cstr(frappe.utils.flt(doc.total_qty, 0)) %}
@@ -46,6 +50,7 @@
<td class="bill-content net-total text-right">{{ doc.get_formatted("grand_total") }}</td> <td class="bill-content net-total text-right">{{ doc.get_formatted("grand_total") }}</td>
</tr> </tr>
</table> </table>
{% endif %}
{% if cart_settings.enable_checkout %} {% if cart_settings.enable_checkout %}
<button class="btn btn-primary btn-place-order font-md w-100" type="button"> <button class="btn btn-primary btn-place-order font-md w-100" type="button">

View File

@@ -101,11 +101,9 @@
</div> </div>
{% endif %} {% endif %}
{% if cart_settings.enable_checkout %}
<div class="mb-3 frappe-card p-5 payment-summary"> <div class="mb-3 frappe-card p-5 payment-summary">
{% include "templates/includes/cart/cart_payment_summary.html" %} {% include "templates/includes/cart/cart_payment_summary.html" %}
</div> </div>
{% endif %}
{% include "templates/includes/cart/cart_address.html" %} {% include "templates/includes/cart/cart_address.html" %}
</div> </div>