mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-16 11:39:18 +00:00
[feature] [website] Create Default Home Page
This commit is contained in:
@@ -39,6 +39,7 @@ class DocType:
|
||||
where company=%s and docstatus<2 limit 1""", self.doc.name):
|
||||
self.create_default_accounts()
|
||||
self.create_default_warehouses()
|
||||
self.create_default_web_page()
|
||||
|
||||
if not self.doc.cost_center:
|
||||
self.create_default_cost_center()
|
||||
@@ -52,8 +53,46 @@ class DocType:
|
||||
for whname in ("Stores", "Work In Progress", "Finished Goods"):
|
||||
webnotes.bean({
|
||||
"doctype":"Warehouse",
|
||||
"warehouse_name": whname,
|
||||
"company": self.doc.name
|
||||
}).insert()
|
||||
|
||||
def create_default_web_page(self):
|
||||
if not webnotes.conn.get_value("Website Settings", None, "home_page"):
|
||||
import os
|
||||
with open(os.path.join(os.path.dirname(__file__), "sample_home_page.html"), "r") as webfile:
|
||||
webpage = webnotes.bean({
|
||||
"doctype": "Web Page",
|
||||
"title": self.doc.name + " Home",
|
||||
"published": 1,
|
||||
"description": "Standard Home Page for " + self.doc.company,
|
||||
"main_section": webfile.read() % self.doc.fields
|
||||
}).insert()
|
||||
|
||||
# update in home page in settings
|
||||
website_settings = webnotes.bean("Website Settings", "Website Settings")
|
||||
website_settings.doc.home_page = webpage.doc.name
|
||||
website_settings.doc.banner_html = """<h3 style='margin-bottom: 20px;'>""" + self.doc.name + "</h3>"
|
||||
website_settings.doc.copyright = self.doc.name
|
||||
website_settings.doclist.append({
|
||||
"doctype": "Top Bar Item",
|
||||
"parentfield": "top_bar_items",
|
||||
"label":"Home",
|
||||
"url": webpage.doc.name
|
||||
})
|
||||
website_settings.doclist.append({
|
||||
"doctype": "Top Bar Item",
|
||||
"parentfield": "top_bar_items",
|
||||
"label":"Contact",
|
||||
"url": "contact"
|
||||
})
|
||||
website_settings.doclist.append({
|
||||
"doctype": "Top Bar Item",
|
||||
"parentfield": "top_bar_items",
|
||||
"label":"Blog",
|
||||
"url": "blog"
|
||||
})
|
||||
website_settings.save()
|
||||
|
||||
def create_default_accounts(self):
|
||||
self.fld_dict = {'account_name':0,'parent_account':1,'group_or_ledger':2,'is_pl_account':3,'account_type':4,'debit_or_credit':5,'company':6,'tax_rate':7}
|
||||
|
||||
22
setup/doctype/company/sample_home_page.html
Normal file
22
setup/doctype/company/sample_home_page.html
Normal file
@@ -0,0 +1,22 @@
|
||||
<h2 style="text-align: center;"><i class="icon-home"></i> Sample Home Page</h2>
|
||||
<br>
|
||||
<p>This is a sample home page for your company <b>%(name)s's</b> website. This was
|
||||
created from the Website Module inside ERPNext. ERPNext provides you with simple
|
||||
tools to build and update your website. You can add sections like your Product Catalog,
|
||||
Blog, Contact Us, About Us and so on. Messages entered in the "Contact" page are
|
||||
automatically added as Leads in the system.
|
||||
|
||||
<h5>What you can do with your website:</h5>
|
||||
|
||||
<ul>
|
||||
<li>Automatically generate products / services catalog from your Items.
|
||||
<li>Capture Leads from your website.
|
||||
<li>Communicate with your customers by sharing your thoughts in your Blog.
|
||||
<li>Introduce your company and team in the About Us page.
|
||||
</ul>
|
||||
|
||||
<p>Infact,
|
||||
<a href="https://erpnext.com" target="_blank">erpnext.com</a>
|
||||
website is built on ERPNext itself.</p>
|
||||
|
||||
<p class="text-muted">For more help, click here</p>
|
||||
Reference in New Issue
Block a user