fix: Website Items with same Item name unhandled, thumbnails missing
- Use naming series for Website Item. There could be two items with same name and different item code - Fix: Website Item Page view breaks if cart is disabled - Fix: thumbnails not created for Website Items after patch - Fix: ‘Request for Quote’ button & cart summary not visible if checkout is disabled
This commit is contained in:
parent
d637f79517
commit
ba52d7c23f
@ -27,6 +27,15 @@ 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 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):
|
def onload(self):
|
||||||
super(WebsiteItem, self).onload()
|
super(WebsiteItem, self).onload()
|
||||||
|
|
||||||
@ -131,7 +140,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
|
||||||
@ -204,7 +213,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]
|
||||||
|
|||||||
@ -16,7 +16,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:
|
||||||
|
|||||||
@ -290,6 +290,9 @@ erpnext.patches.v13_0.validate_options_for_data_field
|
|||||||
erpnext.patches.v13_0.create_gst_payment_entry_fields
|
erpnext.patches.v13_0.create_gst_payment_entry_fields
|
||||||
erpnext.patches.v14_0.delete_shopify_doctypes
|
erpnext.patches.v14_0.delete_shopify_doctypes
|
||||||
erpnext.patches.v13_0.fix_invoice_statuses
|
erpnext.patches.v13_0.fix_invoice_statuses
|
||||||
|
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.replace_supplier_item_group_with_party_specific_item
|
erpnext.patches.v13_0.replace_supplier_item_group_with_party_specific_item
|
||||||
erpnext.patches.v13_0.update_dates_in_tax_withholding_category
|
erpnext.patches.v13_0.update_dates_in_tax_withholding_category
|
||||||
erpnext.patches.v14_0.update_opportunity_currency_fields
|
erpnext.patches.v14_0.update_opportunity_currency_fields
|
||||||
|
|||||||
@ -44,28 +44,32 @@ 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})
|
||||||
|
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)
|
# move Website Item Group & Website Specification table to Website Item
|
||||||
website_item = make_website_item(item, save=False)
|
for doctype in ("Website Item Group", "Item Website Specification"):
|
||||||
website_item.ranking = item.get("weightage")
|
web_item, item_code = website_item.name, item.item_code
|
||||||
for field in web_fields_to_map:
|
frappe.db.sql(f"""
|
||||||
website_item.update({field: item.get(field)})
|
Update
|
||||||
website_item.save()
|
`tab{doctype}`
|
||||||
|
set
|
||||||
# move Website Item Group & Website Specification table to Website Item
|
parenttype = 'Website Item',
|
||||||
for doctype in ("Website Item Group", "Item Website Specification"):
|
parent = '{web_item}'
|
||||||
web_item, item = website_item.name, item.item_code
|
where
|
||||||
frappe.db.sql(f"""
|
parenttype = 'Item'
|
||||||
Update
|
and parent = '{item_code}'
|
||||||
`tab{doctype}`
|
""")
|
||||||
set
|
|
||||||
parenttype = 'Website Item',
|
|
||||||
parent = '{web_item}'
|
|
||||||
where
|
|
||||||
parenttype = 'Item'
|
|
||||||
and parent = '{item_code}'
|
|
||||||
""")
|
|
||||||
|
|
||||||
count += 1
|
count += 1
|
||||||
if count % 20 == 0: # commit after every 20 items
|
if count % 20 == 0: # commit after every 20 items
|
||||||
|
|||||||
@ -1,51 +1,56 @@
|
|||||||
<!-- 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">
|
||||||
<table class="table w-100">
|
{% if cart_settings.enable_checkout or cart_settings.show_price_in_quotation %}
|
||||||
<tr>
|
<table class="table w-100">
|
||||||
{% set total_items = frappe.utils.cstr(frappe.utils.flt(doc.total_qty, 0)) %}
|
<tr>
|
||||||
<td class="bill-label">{{ _("Net Total (") + total_items + _(" Items)") }}</td>
|
{% set total_items = frappe.utils.cstr(frappe.utils.flt(doc.total_qty, 0)) %}
|
||||||
<td class="bill-content net-total text-right">{{ doc.get_formatted("net_total") }}</td>
|
<td class="bill-label">{{ _("Net Total (") + total_items + _(" Items)") }}</td>
|
||||||
</tr>
|
<td class="bill-content net-total text-right">{{ doc.get_formatted("net_total") }}</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
<!-- taxes -->
|
<!-- taxes -->
|
||||||
{% for d in doc.taxes %}
|
{% for d in doc.taxes %}
|
||||||
{% if d.base_tax_amount %}
|
{% if d.base_tax_amount %}
|
||||||
<tr>
|
<tr>
|
||||||
<td class="bill-label">
|
<td class="bill-label">
|
||||||
{{ d.description }}
|
{{ d.description }}
|
||||||
</td>
|
</td>
|
||||||
<td class="bill-content text-right">
|
<td class="bill-content text-right">
|
||||||
{{ d.get_formatted("base_tax_amount") }}
|
{{ d.get_formatted("base_tax_amount") }}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<!-- TODO: Apply Coupon Dialog-->
|
<!-- TODO: Apply Coupon Dialog-->
|
||||||
<!-- {% set show_coupon_code = cart_settings.show_apply_coupon_code_in_website and cart_settings.enable_checkout %}
|
<!-- {% set show_coupon_code = cart_settings.show_apply_coupon_code_in_website and cart_settings.enable_checkout %}
|
||||||
{% if show_coupon_code %}
|
{% if show_coupon_code %}
|
||||||
<button class="btn btn-coupon-code w-100 text-left">
|
<button class="btn btn-coupon-code w-100 text-left">
|
||||||
<svg width="24" height="24" viewBox="0 0 24 24" stroke="var(--gray-600)" fill="none" xmlns="http://www.w3.org/2000/svg">
|
<svg width="24" height="24" viewBox="0 0 24 24" stroke="var(--gray-600)" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
<path d="M19 15.6213C19 15.2235 19.158 14.842 19.4393 14.5607L20.9393 13.0607C21.5251 12.4749 21.5251 11.5251 20.9393 10.9393L19.4393 9.43934C19.158 9.15804 19 8.7765 19 8.37868V6.5C19 5.67157 18.3284 5 17.5 5H15.6213C15.2235 5 14.842 4.84196 14.5607 4.56066L13.0607 3.06066C12.4749 2.47487 11.5251 2.47487 10.9393 3.06066L9.43934 4.56066C9.15804 4.84196 8.7765 5 8.37868 5H6.5C5.67157 5 5 5.67157 5 6.5V8.37868C5 8.7765 4.84196 9.15804 4.56066 9.43934L3.06066 10.9393C2.47487 11.5251 2.47487 12.4749 3.06066 13.0607L4.56066 14.5607C4.84196 14.842 5 15.2235 5 15.6213V17.5C5 18.3284 5.67157 19 6.5 19H8.37868C8.7765 19 9.15804 19.158 9.43934 19.4393L10.9393 20.9393C11.5251 21.5251 12.4749 21.5251 13.0607 20.9393L14.5607 19.4393C14.842 19.158 15.2235 19 15.6213 19H17.5C18.3284 19 19 18.3284 19 17.5V15.6213Z" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"/>
|
<path d="M19 15.6213C19 15.2235 19.158 14.842 19.4393 14.5607L20.9393 13.0607C21.5251 12.4749 21.5251 11.5251 20.9393 10.9393L19.4393 9.43934C19.158 9.15804 19 8.7765 19 8.37868V6.5C19 5.67157 18.3284 5 17.5 5H15.6213C15.2235 5 14.842 4.84196 14.5607 4.56066L13.0607 3.06066C12.4749 2.47487 11.5251 2.47487 10.9393 3.06066L9.43934 4.56066C9.15804 4.84196 8.7765 5 8.37868 5H6.5C5.67157 5 5 5.67157 5 6.5V8.37868C5 8.7765 4.84196 9.15804 4.56066 9.43934L3.06066 10.9393C2.47487 11.5251 2.47487 12.4749 3.06066 13.0607L4.56066 14.5607C4.84196 14.842 5 15.2235 5 15.6213V17.5C5 18.3284 5.67157 19 6.5 19H8.37868C8.7765 19 9.15804 19.158 9.43934 19.4393L10.9393 20.9393C11.5251 21.5251 12.4749 21.5251 13.0607 20.9393L14.5607 19.4393C14.842 19.158 15.2235 19 15.6213 19H17.5C18.3284 19 19 18.3284 19 17.5V15.6213Z" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"/>
|
||||||
<path d="M15 9L9 15" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"/>
|
<path d="M15 9L9 15" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"/>
|
||||||
<path d="M10.5 9.5C10.5 10.0523 10.0523 10.5 9.5 10.5C8.94772 10.5 8.5 10.0523 8.5 9.5C8.5 8.94772 8.94772 8.5 9.5 8.5C10.0523 8.5 10.5 8.94772 10.5 9.5Z" fill="white" stroke-linecap="round" stroke-linejoin="round"/>
|
<path d="M10.5 9.5C10.5 10.0523 10.0523 10.5 9.5 10.5C8.94772 10.5 8.5 10.0523 8.5 9.5C8.5 8.94772 8.94772 8.5 9.5 8.5C10.0523 8.5 10.5 8.94772 10.5 9.5Z" fill="white" stroke-linecap="round" stroke-linejoin="round"/>
|
||||||
<path d="M15.5 14.5C15.5 15.0523 15.0523 15.5 14.5 15.5C13.9477 15.5 13.5 15.0523 13.5 14.5C13.5 13.9477 13.9477 13.5 14.5 13.5C15.0523 13.5 15.5 13.9477 15.5 14.5Z" fill="white" stroke-linecap="round" stroke-linejoin="round"/>
|
<path d="M15.5 14.5C15.5 15.0523 15.0523 15.5 14.5 15.5C13.9477 15.5 13.5 15.0523 13.5 14.5C13.5 13.9477 13.9477 13.5 14.5 13.5C15.0523 13.5 15.5 13.9477 15.5 14.5Z" fill="white" stroke-linecap="round" stroke-linejoin="round"/>
|
||||||
</svg>
|
</svg>
|
||||||
<span class="ml-2">Apply Coupon</span>
|
<span class="ml-2">Apply Coupon</span>
|
||||||
</button>
|
</button>
|
||||||
{% endif %} -->
|
{% endif %} -->
|
||||||
|
|
||||||
<table class="table w-100 grand-total mt-6">
|
<table class="table w-100 grand-total mt-6">
|
||||||
<tr>
|
<tr>
|
||||||
<td class="bill-content net-total">{{ _("Grand Total") }}</td>
|
<td class="bill-content net-total">{{ _("Grand Total") }}</td>
|
||||||
<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">
|
||||||
|
|||||||
@ -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>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user