[feature] [website] Create Default Home Page
This commit is contained in:
parent
994c319c31
commit
e41bceb3df
@ -75,6 +75,7 @@ $.extend(erpnext.complete_setup, {
|
||||
if(!data) return;
|
||||
$(this).set_working();
|
||||
$c_obj('Setup Control','setup_account',data,function(r, rt){
|
||||
$(this).done_working();
|
||||
if(!r.exc) {
|
||||
sys_defaults = r.message;
|
||||
user_fullname = r.message.user_fullname;
|
||||
@ -84,12 +85,16 @@ $.extend(erpnext.complete_setup, {
|
||||
wn.container.wntoolbar.set_user_name();
|
||||
|
||||
setTimeout(function() { window.location.reload(); }, 3000);
|
||||
} else {
|
||||
$(this).done_working();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
d.fields_dict.company_name.input.onchange = function() {
|
||||
var parts = d.get_input("company_name").val().split(" ");
|
||||
var abbr = $.map(parts, function(p) { return p ? p.substr(0,1) : null }).join("");
|
||||
d.get_input("company_abbr").val(abbr.toUpperCase());
|
||||
}
|
||||
|
||||
d.fields_dict.country.input.onchange = function() {
|
||||
var country = d.fields_dict.country.input.value;
|
||||
var $timezone = $(d.fields_dict.timezone.input);
|
||||
|
@ -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>
|
@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2012-07-12 23:29:45",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-07-10 14:54:11",
|
||||
"modified": "2013-07-10 19:24:07",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@ -12,6 +12,7 @@
|
||||
"allow_print": 1,
|
||||
"description": "Send automatic emails to Contacts on Submitting transactions.",
|
||||
"doctype": "DocType",
|
||||
"icon": "icon-envelope",
|
||||
"issingle": 1,
|
||||
"module": "Setup",
|
||||
"name": "__common__"
|
||||
|
@ -65,7 +65,7 @@ class DocType:
|
||||
webnotes.bean([{
|
||||
"doctype":"Fiscal Year",
|
||||
'year': curr_fiscal_year,
|
||||
'year_start_date': fy_start_date,
|
||||
'year_start_date': fy_start_date
|
||||
}]).insert()
|
||||
|
||||
curr_fiscal_year, fy_start_date, fy_abbr = self.get_fy_details(args.get('fy_start'))
|
||||
@ -79,9 +79,10 @@ class DocType:
|
||||
# Company
|
||||
webnotes.bean([{
|
||||
"doctype":"Company",
|
||||
'domain': args.get("industry"),
|
||||
'company_name':args.get('company_name'),
|
||||
'abbr':args.get('company_abbr'),
|
||||
'default_currency':args.get('currency')
|
||||
'default_currency':args.get('currency'),
|
||||
}]).insert()
|
||||
|
||||
self.curr_fiscal_year = curr_fiscal_year
|
||||
@ -148,7 +149,7 @@ class DocType:
|
||||
|
||||
# control panel
|
||||
cp = webnotes.doc("Control Panel", "Control Panel")
|
||||
for k in ['industry', 'country', 'timezone', 'company_name']:
|
||||
for k in ['country', 'timezone', 'company_name']:
|
||||
cp.fields[k] = args[k]
|
||||
|
||||
cp.save()
|
||||
|
@ -146,9 +146,6 @@ def import_defaults():
|
||||
{'doctype': 'Supplier Type', 'supplier_type': 'Hardware'},
|
||||
{'doctype': 'Supplier Type', 'supplier_type': 'Pharmaceutical'},
|
||||
{'doctype': 'Supplier Type', 'supplier_type': 'Distributor'},
|
||||
|
||||
# Workstation
|
||||
{'doctype': 'Workstation', 'name': 'Default Workstation', 'workstation_name': 'Default Workstation', 'warehouse': 'Default Warehouse'},
|
||||
|
||||
# Sales Person
|
||||
{'doctype': 'Sales Person', 'sales_person_name': 'Sales Team', 'is_group': "Yes", "parent_sales_person": ""},
|
||||
@ -166,12 +163,11 @@ def import_defaults():
|
||||
|
||||
from webnotes.modules import scrub
|
||||
for r in records:
|
||||
if not webnotes.conn.exists(r['doctype'], r['name']):
|
||||
bean = webnotes.bean(r)
|
||||
|
||||
# ignore mandatory for root
|
||||
parent_link_field = ("parent_" + scrub(bean.doc.doctype))
|
||||
if parent_link_field in bean.doc.fields and not bean.doc.fields.get(parent_link_field):
|
||||
bean.ignore_mandatory = True
|
||||
|
||||
bean.insert()
|
||||
bean = webnotes.bean(r)
|
||||
|
||||
# ignore mandatory for root
|
||||
parent_link_field = ("parent_" + scrub(bean.doc.doctype))
|
||||
if parent_link_field in bean.doc.fields and not bean.doc.fields.get(parent_link_field):
|
||||
bean.ignore_mandatory = True
|
||||
|
||||
bean.insert()
|
@ -41,6 +41,10 @@ img {
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
div.web-footer {
|
||||
border-top: 1px solid #dddddd;
|
||||
padding-top: 10px;
|
||||
}
|
||||
|
||||
.web-footer-menu ul {
|
||||
list-style: none;
|
||||
|
@ -9,7 +9,7 @@ body {
|
||||
background-color: #{{ doc.background_color }};
|
||||
background-image: none;
|
||||
{% else %}
|
||||
background-color: #edede7;
|
||||
background-color: #ffffff;
|
||||
{% endif %}
|
||||
{% if doc.font or doc.google_web_font_for_text %}
|
||||
font-family: '{{ doc.google_web_font_for_text or doc.font }}', 'Helvetica Neue', Arial, Sans !important;
|
||||
|
@ -34,7 +34,7 @@ $.extend(cur_frm.cscript, {
|
||||
|
||||
url: function(doc, cdt, cdn) {
|
||||
this.label(doc, cdt, cdn);
|
||||
}
|
||||
},
|
||||
|
||||
set_parent_label_options: function() {
|
||||
wn.meta.get_docfield("Top Bar Item", "parent_label", cur_frm.docname).options =
|
||||
|
@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-04-30 12:58:46",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-07-05 15:02:50",
|
||||
"modified": "2013-07-10 20:37:38",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
|
@ -1,4 +1,4 @@
|
||||
<div class="navbar navbar-inverse" style="">
|
||||
<div class="navbar" style="margin: 0px -15px">
|
||||
{%- if brand_html %}<a class="navbar-brand" href="index">{{ brand_html }}</a>{% endif -%}
|
||||
<div class="container">
|
||||
<button type="button" class="navbar-toggle" data-toggle="collapse"
|
||||
|
Loading…
x
Reference in New Issue
Block a user