diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index 65c646ac05..6045e77384 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -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_duplicate_bins
erpnext.patches.v6_4.fix_sales_order_maintenance_status
-<<<<<<< HEAD
erpnext.patches.v6_4.email_digest_update
# delete shopping cart doctypes
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 Taxes and Charges Master")
-=======
erpnext.patches.v6_4.set_user_in_contact
->>>>>>> [minor] Added 'Invite User' in Contact
+erpnext.patches.v6_4.make_image_thumbnail
diff --git a/erpnext/patches/v6_4/make_image_thumbnail.py b/erpnext/patches/v6_4/make_image_thumbnail.py
new file mode 100644
index 0000000000..60219e42df
--- /dev/null
+++ b/erpnext/patches/v6_4/make_image_thumbnail.py
@@ -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)
diff --git a/erpnext/patches/v6_4/set_user_in_contact.py b/erpnext/patches/v6_4/set_user_in_contact.py
index 509114bbd5..41f76af94d 100644
--- a/erpnext/patches/v6_4/set_user_in_contact.py
+++ b/erpnext/patches/v6_4/set_user_in_contact.py
@@ -1,5 +1,6 @@
import frappe
def execute():
+ frappe.reload_doctype("Contact")
frappe.db.sql("""update tabContact, tabUser set tabContact.user = tabUser.name
where tabContact.email_id = tabUser.email""")
diff --git a/erpnext/setup/doctype/item_group/item_group.py b/erpnext/setup/doctype/item_group/item_group.py
index 61a907bc67..97367013d7 100644
--- a/erpnext/setup/doctype/item_group/item_group.py
+++ b/erpnext/setup/doctype/item_group/item_group.py
@@ -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)])
# 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,
concat(parent_website_route, "/", page_name) as route
from `tabItem`
diff --git a/erpnext/shopping_cart/cart.py b/erpnext/shopping_cart/cart.py
index c4f3db0395..22f920faa6 100644
--- a/erpnext/shopping_cart/cart.py
+++ b/erpnext/shopping_cart/cart.py
@@ -143,7 +143,7 @@ def guess_territory():
def decorate_quotation_doc(doc):
for d in doc.get("items", []):
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
diff --git a/erpnext/stock/doctype/item/item.json b/erpnext/stock/doctype/item/item.json
index 4de617a5a3..fcb696a912 100644
--- a/erpnext/stock/doctype/item/item.json
+++ b/erpnext/stock/doctype/item/item.json
@@ -1902,6 +1902,28 @@
"set_only_once": 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,
"bold": 0,
diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py
index 819fbcac54..41329f3b4c 100644
--- a/erpnext/stock/doctype/item/item.py
+++ b/erpnext/stock/doctype/item/item.py
@@ -66,6 +66,7 @@ class Item(WebsiteGenerator):
self.validate_has_variants()
self.validate_attributes()
self.validate_variant_attributes()
+ self.make_thumbnail()
if not self.get("__islocal"):
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_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):
context.parent_groups = get_parent_item_groups(self.item_group) + \
[{"name": self.name}]
diff --git a/erpnext/templates/generators/item.html b/erpnext/templates/generators/item.html
index 30ccbceacd..f24b1a678b 100644
--- a/erpnext/templates/generators/item.html
+++ b/erpnext/templates/generators/item.html
@@ -94,6 +94,8 @@
{% if variant_info %}
window.variant_info = {{ variant_info }};
+ {% else %}
+ window.variant_info = null;
{% endif %}
{% endblock %}
diff --git a/erpnext/templates/includes/product_in_grid.html b/erpnext/templates/includes/product_in_grid.html
index d2c1c46ee6..ff39f1f8c2 100644
--- a/erpnext/templates/includes/product_in_grid.html
+++ b/erpnext/templates/includes/product_in_grid.html
@@ -2,7 +2,7 @@