brotherton-erpnext/erpnext/patches/v7_0/update_home_page.py

27 lines
963 B
Python
Raw Normal View History

2016-05-12 09:52:59 +00:00
import frappe
import erpnext
def execute():
2016-05-20 05:11:50 +00:00
frappe.reload_doc('portal', 'doctype', 'homepage_featured_product')
2016-05-17 20:16:23 +00:00
frappe.reload_doc('portal', 'doctype', 'homepage')
2016-05-20 05:11:50 +00:00
frappe.reload_doc('portal', 'doctype', 'products_settings')
2016-07-22 15:30:12 +00:00
frappe.reload_doctype('Item')
frappe.reload_doctype('Item Group')
2016-05-16 06:11:29 +00:00
2016-05-12 09:52:59 +00:00
website_settings = frappe.get_doc('Website Settings', 'Website Settings')
if frappe.db.exists('Web Page', website_settings.home_page):
header = frappe.db.get_value('Web Page', website_settings.home_page, 'header')
if header and header.startswith("<div class='hero text-center'>"):
homepage = frappe.get_doc('Homepage', 'Homepage')
homepage.company = erpnext.get_default_company()
2016-06-01 06:59:08 +00:00
if '<h1>' in header:
homepage.tag_line = header.split('<h1>')[1].split('</h1>')[0] or 'Default Website'
else:
homepage.tag_line = 'Default Website'
2016-05-12 09:52:59 +00:00
homepage.setup_items()
homepage.save()
website_settings.home_page = 'home'
website_settings.save()