[enhancement] use thumbnails in grid views, patch to make thumbnails
This commit is contained in:
parent
73e73795f1
commit
6e322d0a02
@ -218,13 +218,11 @@ erpnext.patches.v6_4.fix_status_in_sales_and_purchase_order
|
|||||||
erpnext.patches.v6_4.fix_modified_in_sales_order_and_purchase_order
|
erpnext.patches.v6_4.fix_modified_in_sales_order_and_purchase_order
|
||||||
erpnext.patches.v6_4.fix_duplicate_bins
|
erpnext.patches.v6_4.fix_duplicate_bins
|
||||||
erpnext.patches.v6_4.fix_sales_order_maintenance_status
|
erpnext.patches.v6_4.fix_sales_order_maintenance_status
|
||||||
<<<<<<< HEAD
|
|
||||||
erpnext.patches.v6_4.email_digest_update
|
erpnext.patches.v6_4.email_digest_update
|
||||||
|
|
||||||
# delete shopping cart doctypes
|
# delete shopping cart doctypes
|
||||||
execute:frappe.delete_doc_if_exists("DocType", "Applicable Territory")
|
execute:frappe.delete_doc_if_exists("DocType", "Applicable Territory")
|
||||||
execute:frappe.delete_doc_if_exists("DocType", "Shopping Cart Price List")
|
execute:frappe.delete_doc_if_exists("DocType", "Shopping Cart Price List")
|
||||||
execute:frappe.delete_doc_if_exists("DocType", "Shopping Cart Taxes and Charges Master")
|
execute:frappe.delete_doc_if_exists("DocType", "Shopping Cart Taxes and Charges Master")
|
||||||
=======
|
|
||||||
erpnext.patches.v6_4.set_user_in_contact
|
erpnext.patches.v6_4.set_user_in_contact
|
||||||
>>>>>>> [minor] Added 'Invite User' in Contact
|
erpnext.patches.v6_4.make_image_thumbnail
|
||||||
|
14
erpnext/patches/v6_4/make_image_thumbnail.py
Normal file
14
erpnext/patches/v6_4/make_image_thumbnail.py
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import frappe
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
frappe.reload_doctype("File")
|
||||||
|
frappe.reload_doctype("Item")
|
||||||
|
for item in frappe.get_all("Item", fields=("name", "website_image")):
|
||||||
|
if item.website_image:
|
||||||
|
item_doc = frappe.get_doc("Item", item.name)
|
||||||
|
try:
|
||||||
|
item_doc.make_thumbnail()
|
||||||
|
if item_doc.thumbnail:
|
||||||
|
item_doc.db_set("thumbnail", item_doc.thumbnail)
|
||||||
|
except Exception:
|
||||||
|
print "Unable to make thumbnail for {0}".format(item.website_image)
|
@ -1,5 +1,6 @@
|
|||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
def execute():
|
def execute():
|
||||||
|
frappe.reload_doctype("Contact")
|
||||||
frappe.db.sql("""update tabContact, tabUser set tabContact.user = tabUser.name
|
frappe.db.sql("""update tabContact, tabUser set tabContact.user = tabUser.name
|
||||||
where tabContact.email_id = tabUser.email""")
|
where tabContact.email_id = tabUser.email""")
|
||||||
|
@ -66,7 +66,7 @@ def get_product_list_for_group(product_group=None, start=0, limit=10):
|
|||||||
child_groups = ", ".join(['"' + i[0] + '"' for i in get_child_groups(product_group)])
|
child_groups = ", ".join(['"' + i[0] + '"' for i in get_child_groups(product_group)])
|
||||||
|
|
||||||
# base query
|
# base query
|
||||||
query = """select name, item_name, page_name, website_image, item_group,
|
query = """select name, item_name, page_name, website_image, thumbnail, item_group,
|
||||||
web_long_description as website_description,
|
web_long_description as website_description,
|
||||||
concat(parent_website_route, "/", page_name) as route
|
concat(parent_website_route, "/", page_name) as route
|
||||||
from `tabItem`
|
from `tabItem`
|
||||||
|
@ -143,7 +143,7 @@ def guess_territory():
|
|||||||
def decorate_quotation_doc(doc):
|
def decorate_quotation_doc(doc):
|
||||||
for d in doc.get("items", []):
|
for d in doc.get("items", []):
|
||||||
d.update(frappe.db.get_value("Item", d.item_code,
|
d.update(frappe.db.get_value("Item", d.item_code,
|
||||||
["website_image", "description", "page_name"], as_dict=True))
|
["thumbnail", "website_image", "description", "page_name"], as_dict=True))
|
||||||
|
|
||||||
return doc
|
return doc
|
||||||
|
|
||||||
|
@ -1902,6 +1902,28 @@
|
|||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"bold": 0,
|
||||||
|
"collapsible": 0,
|
||||||
|
"fieldname": "thumbnail",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"hidden": 0,
|
||||||
|
"ignore_user_permissions": 0,
|
||||||
|
"in_filter": 0,
|
||||||
|
"in_list_view": 0,
|
||||||
|
"label": "Thumbnail",
|
||||||
|
"no_copy": 0,
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 0,
|
||||||
|
"read_only": 1,
|
||||||
|
"report_hide": 0,
|
||||||
|
"reqd": 0,
|
||||||
|
"search_index": 0,
|
||||||
|
"set_only_once": 0,
|
||||||
|
"unique": 0
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
|
@ -66,6 +66,7 @@ class Item(WebsiteGenerator):
|
|||||||
self.validate_has_variants()
|
self.validate_has_variants()
|
||||||
self.validate_attributes()
|
self.validate_attributes()
|
||||||
self.validate_variant_attributes()
|
self.validate_variant_attributes()
|
||||||
|
self.make_thumbnail()
|
||||||
|
|
||||||
if not self.get("__islocal"):
|
if not self.get("__islocal"):
|
||||||
self.old_item_group = frappe.db.get_value(self.doctype, self.name, "item_group")
|
self.old_item_group = frappe.db.get_value(self.doctype, self.name, "item_group")
|
||||||
@ -79,6 +80,26 @@ class Item(WebsiteGenerator):
|
|||||||
self.update_item_price()
|
self.update_item_price()
|
||||||
self.update_variants()
|
self.update_variants()
|
||||||
|
|
||||||
|
def make_thumbnail(self):
|
||||||
|
"""Make a thumbnail of `website_image`"""
|
||||||
|
if self.website_image and not self.thumbnail:
|
||||||
|
file_doc = frappe.get_doc("File", {
|
||||||
|
"file_url": self.website_image,
|
||||||
|
"attached_to_doctype": "Item",
|
||||||
|
"attached_to_name": self.name
|
||||||
|
})
|
||||||
|
|
||||||
|
if not file_doc:
|
||||||
|
file_doc = frappe.get_doc({
|
||||||
|
"doctype": "File",
|
||||||
|
"file_url": self.website_image,
|
||||||
|
"attached_to_doctype": "Item",
|
||||||
|
"attached_to_name": self.name
|
||||||
|
}).insert()
|
||||||
|
|
||||||
|
if file_doc:
|
||||||
|
self.thumbnail = file_doc.make_thumbnail()
|
||||||
|
|
||||||
def get_context(self, context):
|
def get_context(self, context):
|
||||||
context.parent_groups = get_parent_item_groups(self.item_group) + \
|
context.parent_groups = get_parent_item_groups(self.item_group) + \
|
||||||
[{"name": self.name}]
|
[{"name": self.name}]
|
||||||
|
@ -94,6 +94,8 @@
|
|||||||
|
|
||||||
{% if variant_info %}
|
{% if variant_info %}
|
||||||
window.variant_info = {{ variant_info }};
|
window.variant_info = {{ variant_info }};
|
||||||
|
{% else %}
|
||||||
|
window.variant_info = null;
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<a class="product-link" href="{{ (route or page_name)|abs_url }}">
|
<a class="product-link" href="{{ (route or page_name)|abs_url }}">
|
||||||
<div class="col-sm-2 col-xs-4 product-image-wrapper">
|
<div class="col-sm-2 col-xs-4 product-image-wrapper">
|
||||||
{{ product_image_square(website_image) }}
|
{{ product_image_square(thumbnail or website_image) }}
|
||||||
<div class="text-ellipsis inline-block small product-text">{{ item_name }}</div>
|
<div class="text-ellipsis inline-block small product-text">{{ item_name }}</div>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
|
@ -3,7 +3,8 @@
|
|||||||
<div style="height: 120px; overflow: hidden;">
|
<div style="height: 120px; overflow: hidden;">
|
||||||
<a href="{{ (route or page_name)|abs_url }}">
|
<a href="{{ (route or page_name)|abs_url }}">
|
||||||
{%- if website_image -%}
|
{%- if website_image -%}
|
||||||
<img class="product-image" style="width: 80%; margin: auto;" src="{{ website_image|abs_url }}">
|
<img class="product-image" style="width: 80%; margin: auto;" src="{{
|
||||||
|
(thumbnail or website_image)|abs_url }}">
|
||||||
{%- else -%}
|
{%- else -%}
|
||||||
<div style="width: 80%; height: 120px; background-color: #F7FAFC;"></div>
|
<div style="width: 80%; height: 120px; background-color: #F7FAFC;"></div>
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
|
@ -12,7 +12,7 @@ no_sitemap = 1
|
|||||||
@frappe.whitelist(allow_guest=True)
|
@frappe.whitelist(allow_guest=True)
|
||||||
def get_product_list(search=None, start=0, limit=10):
|
def get_product_list(search=None, start=0, limit=10):
|
||||||
# base query
|
# base query
|
||||||
query = """select name, item_name, page_name, website_image, item_group,
|
query = """select name, item_name, page_name, website_image, thumbnail, item_group,
|
||||||
web_long_description as website_description, parent_website_route
|
web_long_description as website_description, parent_website_route
|
||||||
from `tabItem` where show_in_website = 1 and (variant_of is null or variant_of = '')"""
|
from `tabItem` where show_in_website = 1 and (variant_of is null or variant_of = '')"""
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user