fix: Map Item
image to Website Item
website_image only if published via UI (v13)
- For v12 Items, `website_image` should be mapped from `Item` to `Website Item`
This commit is contained in:
parent
d2d651a0c3
commit
af38baeb3b
@ -1,8 +1,12 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors
|
# Copyright (c) 2022, Frappe Technologies Pvt. Ltd. and contributors
|
||||||
# For license information, please see license.txt
|
# For license information, please see license.txt
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
from typing import TYPE_CHECKING, List, Union
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from erpnext.stock.doctype.item.item import Item
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
from frappe import _
|
||||||
@ -423,7 +427,9 @@ def check_if_user_is_customer(user=None):
|
|||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def make_website_item(doc, save=True):
|
def make_website_item(doc: "Item", save: bool = True) -> Union["WebsiteItem", List[str]]:
|
||||||
|
"Make Website Item from Item. Used via Form UI or patch."
|
||||||
|
|
||||||
if not doc:
|
if not doc:
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -450,7 +456,8 @@ def make_website_item(doc, save=True):
|
|||||||
for field in fields_to_map:
|
for field in fields_to_map:
|
||||||
website_item.update({field: doc.get(field)})
|
website_item.update({field: doc.get(field)})
|
||||||
|
|
||||||
if doc.get("image") and not website_item.website_image:
|
# Needed for publishing/mapping via Form UI only
|
||||||
|
if not frappe.flags.in_migrate and (doc.get("image") and not website_item.website_image):
|
||||||
website_item.website_image = doc.get("image")
|
website_item.website_image = doc.get("image")
|
||||||
|
|
||||||
if not save:
|
if not save:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user