-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
38c6fe3
commit 1457893
Showing
7 changed files
with
159 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[pre_model_sync] | ||
|
||
[post_model_sync] | ||
|
||
webshop.patches.add_homepage_field |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import frappe | ||
from frappe.custom.doctype.custom_field.custom_field import create_custom_fields | ||
|
||
def execute(): | ||
if not frappe.db.exists("Custom Field", | ||
{"fieldname": "products", "dt": "Homepage"} | ||
): | ||
custom_fields = { | ||
"Homepage": [ | ||
dict( | ||
fieldname="products_section_break", | ||
label="Products", | ||
fieldtype="Section Break", | ||
insert_after="hero_section", | ||
), | ||
dict( | ||
fieldname="products_url", | ||
label="URL for All Products", | ||
fieldtype="Data", | ||
insert_after="products_section_break", | ||
), | ||
dict( | ||
fieldname="products", | ||
label="Products", | ||
fieldtype="Table", | ||
insert_after="products_url", | ||
options="Homepage Featured Product", | ||
), | ||
], | ||
} | ||
|
||
create_custom_fields(custom_fields) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
frappe.ui.form.on('Homepage', { | ||
setup: function(frm) { | ||
frm.fields_dict['products'].grid.get_field('item_code').get_query = function() { | ||
return { | ||
filters: {'published': 1} | ||
} | ||
} | ||
}, | ||
}); | ||
|
||
frappe.ui.form.on('Homepage Featured Product', { | ||
view: function(frm, cdt, cdn) { | ||
var child= locals[cdt][cdn]; | ||
if (child.item_code && child.route) { | ||
window.open('/' + child.route, '_blank'); | ||
} | ||
} | ||
}); |
Empty file.
94 changes: 94 additions & 0 deletions
94
webshop/webshop/doctype/homepage_featured_product/homepage_featured_product.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
{ | ||
"actions": [], | ||
"allow_rename": 1, | ||
"creation": "2023-12-14 22:14:23.853797", | ||
"doctype": "DocType", | ||
"editable_grid": 1, | ||
"engine": "InnoDB", | ||
"field_order": [ | ||
"item_code", | ||
"view", | ||
"column_break_nxmx", | ||
"item_name", | ||
"section_break_qlos", | ||
"description", | ||
"column_break_jxff", | ||
"image", | ||
"thumbnail", | ||
"route" | ||
], | ||
"fields": [ | ||
{ | ||
"fieldname": "item_code", | ||
"fieldtype": "Link", | ||
"in_list_view": 1, | ||
"label": "Item", | ||
"options": "Website Item", | ||
"reqd": 1 | ||
}, | ||
{ | ||
"fieldname": "column_break_nxmx", | ||
"fieldtype": "Column Break" | ||
}, | ||
{ | ||
"fetch_from": "item_code.item_name", | ||
"fieldname": "item_name", | ||
"fieldtype": "Data", | ||
"in_list_view": 1, | ||
"label": "Item Name" | ||
}, | ||
{ | ||
"fieldname": "view", | ||
"fieldtype": "Button", | ||
"in_list_view": 1, | ||
"label": "View" | ||
}, | ||
{ | ||
"fieldname": "section_break_qlos", | ||
"fieldtype": "Section Break" | ||
}, | ||
{ | ||
"fetch_from": "item_code.web_long_description", | ||
"fieldname": "description", | ||
"fieldtype": "Text Editor", | ||
"in_list_view": 1, | ||
"label": "Description" | ||
}, | ||
{ | ||
"fieldname": "column_break_jxff", | ||
"fieldtype": "Column Break" | ||
}, | ||
{ | ||
"fetch_from": "item_code.website_image", | ||
"fetch_if_empty": 1, | ||
"fieldname": "image", | ||
"fieldtype": "Attach Image", | ||
"label": "Image" | ||
}, | ||
{ | ||
"fetch_from": "item_code.thumbnail", | ||
"fieldname": "thumbnail", | ||
"fieldtype": "Attach Image", | ||
"label": "Thumbnail" | ||
}, | ||
{ | ||
"fetch_from": "item_code.route", | ||
"fieldname": "route", | ||
"fieldtype": "Small Text", | ||
"label": "Route", | ||
"read_only": 1 | ||
} | ||
], | ||
"index_web_pages_for_search": 1, | ||
"istable": 1, | ||
"links": [], | ||
"modified": "2023-12-14 22:33:25.457721", | ||
"modified_by": "Administrator", | ||
"module": "Webshop", | ||
"name": "Homepage Featured Product", | ||
"owner": "Administrator", | ||
"permissions": [], | ||
"sort_field": "modified", | ||
"sort_order": "DESC", | ||
"states": [] | ||
} |
9 changes: 9 additions & 0 deletions
9
webshop/webshop/doctype/homepage_featured_product/homepage_featured_product.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Copyright (c) 2023, Frappe Technologies Pvt. Ltd. and contributors | ||
# For license information, please see license.txt | ||
|
||
# import frappe | ||
from frappe.model.document import Document | ||
|
||
|
||
class HomepageFeaturedProduct(Document): | ||
pass |
1457893
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sufficient for me on a new installation
I think fields/custom fields must be integrated to homepage.json file, in erpnext or in webshop by overriding homepage.json
I think the patch is not applying on a fresh install
Error remains the same