Merge branch 'develop' into make-image-field-obsolete-in-web-item
diff --git a/erpnext/e_commerce/doctype/recommended_items/recommended_items.json b/erpnext/e_commerce/doctype/recommended_items/recommended_items.json
index 06ac3dc..1821532 100644
--- a/erpnext/e_commerce/doctype/recommended_items/recommended_items.json
+++ b/erpnext/e_commerce/doctype/recommended_items/recommended_items.json
@@ -48,7 +48,7 @@
"read_only": 1
},
{
- "fetch_from": "website_item.image",
+ "fetch_from": "website_item.website_image",
"fieldname": "website_item_image",
"fieldtype": "Attach",
"label": "Website Item Image",
@@ -75,7 +75,7 @@
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
- "modified": "2021-07-13 21:02:19.031652",
+ "modified": "2022-06-28 16:44:24.718728",
"modified_by": "Administrator",
"module": "E-commerce",
"name": "Recommended Items",
@@ -83,5 +83,6 @@
"permissions": [],
"sort_field": "modified",
"sort_order": "DESC",
+ "states": [],
"track_changes": 1
}
\ No newline at end of file
diff --git a/erpnext/e_commerce/doctype/website_item/website_item.js b/erpnext/e_commerce/doctype/website_item/website_item.js
index 7295e4b..7b7193e 100644
--- a/erpnext/e_commerce/doctype/website_item/website_item.js
+++ b/erpnext/e_commerce/doctype/website_item/website_item.js
@@ -30,10 +30,6 @@
}, __("View"));
},
- image: () => {
- refresh_field("image_view");
- },
-
copy_from_item_group: (frm) => {
return frm.call({
doc: frm.doc,
diff --git a/erpnext/e_commerce/doctype/website_item/website_item.json b/erpnext/e_commerce/doctype/website_item/website_item.json
index 245042a..a416aac 100644
--- a/erpnext/e_commerce/doctype/website_item/website_item.json
+++ b/erpnext/e_commerce/doctype/website_item/website_item.json
@@ -22,7 +22,6 @@
"column_break_11",
"description",
"brand",
- "image",
"display_section",
"website_image",
"website_image_alt",
@@ -113,8 +112,11 @@
{
"description": "Item Image (if not slideshow)",
"fieldname": "website_image",
- "fieldtype": "Attach",
- "label": "Website Image"
+ "fieldtype": "Attach Image",
+ "hidden": 1,
+ "in_preview": 1,
+ "label": "Website Image",
+ "print_hide": 1
},
{
"description": "Image Alternative Text",
@@ -189,14 +191,6 @@
"read_only": 1
},
{
- "fieldname": "image",
- "fieldtype": "Attach Image",
- "hidden": 1,
- "in_preview": 1,
- "label": "Image",
- "print_hide": 1
- },
- {
"default": "1",
"fieldname": "published",
"fieldtype": "Check",
@@ -348,13 +342,14 @@
}
],
"has_web_view": 1,
- "image_field": "image",
+ "image_field": "website_image",
"index_web_pages_for_search": 1,
"links": [],
- "modified": "2021-09-02 13:08:41.942726",
+ "modified": "2022-06-28 17:10:30.613251",
"modified_by": "Administrator",
"module": "E-commerce",
"name": "Website Item",
+ "naming_rule": "Expression (old style)",
"owner": "Administrator",
"permissions": [
{
@@ -410,6 +405,7 @@
"show_name_in_global_search": 1,
"sort_field": "modified",
"sort_order": "DESC",
+ "states": [],
"title_field": "web_item_name",
"track_changes": 1
}
\ No newline at end of file
diff --git a/erpnext/e_commerce/doctype/website_item/website_item.py b/erpnext/e_commerce/doctype/website_item/website_item.py
index f6fea72..098de02 100644
--- a/erpnext/e_commerce/doctype/website_item/website_item.py
+++ b/erpnext/e_commerce/doctype/website_item/website_item.py
@@ -114,11 +114,6 @@
return
"""Validate if the website image is a public file"""
- auto_set_website_image = False
- if not self.website_image and self.image:
- auto_set_website_image = True
- self.website_image = self.image
-
if not self.website_image:
return
@@ -135,18 +130,16 @@
file_doc = file_doc[0]
if not file_doc:
- if not auto_set_website_image:
- frappe.msgprint(
- _("Website Image {0} attached to Item {1} cannot be found").format(
- self.website_image, self.name
- )
+ frappe.msgprint(
+ _("Website Image {0} attached to Item {1} cannot be found").format(
+ self.website_image, self.name
)
+ )
self.website_image = None
elif file_doc.is_private:
- if not auto_set_website_image:
- frappe.msgprint(_("Website Image should be a public file or website URL"))
+ frappe.msgprint(_("Website Image should be a public file or website URL"))
self.website_image = None
@@ -157,9 +150,8 @@
import requests.exceptions
- if not self.is_new() and self.website_image != frappe.db.get_value(
- self.doctype, self.name, "website_image"
- ):
+ db_website_image = frappe.db.get_value(self.doctype, self.name, "website_image")
+ if not self.is_new() and self.website_image != db_website_image:
self.thumbnail = None
if self.website_image and not self.thumbnail:
@@ -451,7 +443,6 @@
"item_group",
"stock_uom",
"brand",
- "image",
"has_variants",
"variant_of",
"description",
@@ -459,6 +450,9 @@
for field in fields_to_map:
website_item.update({field: doc.get(field)})
+ if doc.get("image") and not website_item.website_image:
+ website_item.website_image = doc.get("image")
+
if not save:
return website_item
diff --git a/erpnext/e_commerce/doctype/website_item/website_item_list.js b/erpnext/e_commerce/doctype/website_item/website_item_list.js
index 21be942..b9dd921 100644
--- a/erpnext/e_commerce/doctype/website_item/website_item_list.js
+++ b/erpnext/e_commerce/doctype/website_item/website_item_list.js
@@ -1,5 +1,5 @@
frappe.listview_settings['Website Item'] = {
- add_fields: ["item_name", "web_item_name", "published", "image", "has_variants", "variant_of"],
+ add_fields: ["item_name", "web_item_name", "published", "website_image", "has_variants", "variant_of"],
filters: [["published", "=", "1"]],
get_indicator: function(doc) {
diff --git a/erpnext/e_commerce/doctype/wishlist/wishlist.py b/erpnext/e_commerce/doctype/wishlist/wishlist.py
index 5d6ab41..eb74027 100644
--- a/erpnext/e_commerce/doctype/wishlist/wishlist.py
+++ b/erpnext/e_commerce/doctype/wishlist/wishlist.py
@@ -20,7 +20,15 @@
web_item_data = frappe.db.get_value(
"Website Item",
{"item_code": item_code},
- ["image", "website_warehouse", "name", "web_item_name", "item_name", "item_group", "route"],
+ [
+ "website_image",
+ "website_warehouse",
+ "name",
+ "web_item_name",
+ "item_name",
+ "item_group",
+ "route",
+ ],
as_dict=1,
)
@@ -30,7 +38,7 @@
"item_group": web_item_data.get("item_group"),
"website_item": web_item_data.get("name"),
"web_item_name": web_item_data.get("web_item_name"),
- "image": web_item_data.get("image"),
+ "image": web_item_data.get("website_image"),
"warehouse": web_item_data.get("website_warehouse"),
"route": web_item_data.get("route"),
}
diff --git a/erpnext/e_commerce/product_data_engine/query.py b/erpnext/e_commerce/product_data_engine/query.py
index 5a75382..e6a595a 100644
--- a/erpnext/e_commerce/product_data_engine/query.py
+++ b/erpnext/e_commerce/product_data_engine/query.py
@@ -35,7 +35,6 @@
"variant_of",
"has_variants",
"item_group",
- "image",
"web_long_description",
"short_description",
"route",
diff --git a/erpnext/e_commerce/product_ui/grid.js b/erpnext/e_commerce/product_ui/grid.js
index 9eb1d45..20a6c30 100644
--- a/erpnext/e_commerce/product_ui/grid.js
+++ b/erpnext/e_commerce/product_ui/grid.js
@@ -35,7 +35,7 @@
}
get_image_html(item, title) {
- let image = item.website_image || item.image;
+ let image = item.website_image;
if (image) {
return `
diff --git a/erpnext/e_commerce/product_ui/list.js b/erpnext/e_commerce/product_ui/list.js
index 691cd4d..894a7cb 100644
--- a/erpnext/e_commerce/product_ui/list.js
+++ b/erpnext/e_commerce/product_ui/list.js
@@ -35,7 +35,7 @@
}
get_image_html(item, title, settings) {
- let image = item.website_image || item.image;
+ let image = item.website_image;
let wishlist_enabled = !item.has_variants && settings.enable_wishlist;
let image_html = ``;
diff --git a/erpnext/patches/v13_0/create_website_items.py b/erpnext/patches/v13_0/create_website_items.py
index cb7bfc3..b010f0e 100644
--- a/erpnext/patches/v13_0/create_website_items.py
+++ b/erpnext/patches/v13_0/create_website_items.py
@@ -17,7 +17,6 @@
"item_group",
"stock_uom",
"brand",
- "image",
"has_variants",
"variant_of",
"description",
@@ -30,6 +29,7 @@
"website_warehouse",
"web_long_description",
"website_content",
+ "website_image",
"thumbnail",
]
diff --git a/erpnext/portal/doctype/homepage/homepage.py b/erpnext/portal/doctype/homepage/homepage.py
index 5bb05f0..0d2e360 100644
--- a/erpnext/portal/doctype/homepage/homepage.py
+++ b/erpnext/portal/doctype/homepage/homepage.py
@@ -16,7 +16,7 @@
def setup_items(self):
for d in frappe.get_all(
"Website Item",
- fields=["name", "item_name", "description", "image", "route"],
+ fields=["name", "item_name", "description", "website_image", "route"],
filters={"published": 1},
limit=3,
):
@@ -31,7 +31,7 @@
item_code=d.name,
item_name=d.item_name,
description=d.description,
- image=d.image,
+ image=d.website_image,
route=d.route,
),
)
diff --git a/erpnext/templates/generators/item/item_image.html b/erpnext/templates/generators/item/item_image.html
index 930bb7a..e1bb3b9 100644
--- a/erpnext/templates/generators/item/item_image.html
+++ b/erpnext/templates/generators/item/item_image.html
@@ -24,7 +24,7 @@
})
</script>
{% else %}
- {{ product_image(doc.website_image or doc.image, alt=doc.website_image_alt or doc.item_name) }}
+ {{ product_image(doc.website_image, alt=doc.website_image_alt or doc.item_name) }}
{% endif %}
<!-- Simple image preview -->
diff --git a/erpnext/templates/includes/macros.html b/erpnext/templates/includes/macros.html
index fb4cecf..3e20e50 100644
--- a/erpnext/templates/includes/macros.html
+++ b/erpnext/templates/includes/macros.html
@@ -74,7 +74,7 @@
{%- set col_size = 3 if is_full_width else 4 -%}
{%- set title = item.web_item_name or item.item_name or item.item_code -%}
{%- set title = title[:50] + "..." if title|len > 50 else title -%}
-{%- set image = item.website_image or item.image -%}
+{%- set image = item.website_image -%}
{%- set description = item.website_description or item.description-%}
{% if is_featured %}