[fix] thumbnail generation for item
This commit is contained in:
parent
1d093a4039
commit
b4e9c1da64
@ -82,6 +82,9 @@ class Item(WebsiteGenerator):
|
|||||||
|
|
||||||
def make_thumbnail(self):
|
def make_thumbnail(self):
|
||||||
"""Make a thumbnail of `website_image`"""
|
"""Make a thumbnail of `website_image`"""
|
||||||
|
if not self.is_new() and self.website_image != frappe.db.get_value(self.doctype, self.name, "website_image"):
|
||||||
|
self.thumbnail = None
|
||||||
|
|
||||||
if self.website_image and not self.thumbnail:
|
if self.website_image and not self.thumbnail:
|
||||||
file_doc = frappe.get_doc("File", {
|
file_doc = frappe.get_doc("File", {
|
||||||
"file_url": self.website_image,
|
"file_url": self.website_image,
|
||||||
@ -89,6 +92,7 @@ class Item(WebsiteGenerator):
|
|||||||
"attached_to_name": self.name
|
"attached_to_name": self.name
|
||||||
})
|
})
|
||||||
|
|
||||||
|
# for CSV import
|
||||||
if not file_doc:
|
if not file_doc:
|
||||||
file_doc = frappe.get_doc({
|
file_doc = frappe.get_doc({
|
||||||
"doctype": "File",
|
"doctype": "File",
|
||||||
@ -98,7 +102,10 @@ class Item(WebsiteGenerator):
|
|||||||
}).insert()
|
}).insert()
|
||||||
|
|
||||||
if file_doc:
|
if file_doc:
|
||||||
self.thumbnail = file_doc.make_thumbnail()
|
if not file_doc.thumbnail_url:
|
||||||
|
file_doc.make_thumbnail()
|
||||||
|
|
||||||
|
self.thumbnail = file_doc.thumbnail_url
|
||||||
|
|
||||||
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) + \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user