[demo] New ERPNext Demo
This commit is contained in:
parent
cf343174a4
commit
acd3367e33
@ -1,4 +1,5 @@
|
||||
{
|
||||
"app_name": "ERPNext",
|
||||
"modules": {
|
||||
"Selling": {
|
||||
"link": "selling-home",
|
||||
|
0
utilities/demo/__init__.py
Normal file
0
utilities/demo/__init__.py
Normal file
3
utilities/demo/demo-login.css
Normal file
3
utilities/demo/demo-login.css
Normal file
@ -0,0 +1,3 @@
|
||||
body, #container, .outer {
|
||||
background-color: #888 !important;
|
||||
}
|
25
utilities/demo/demo-login.html
Normal file
25
utilities/demo/demo-login.html
Normal file
@ -0,0 +1,25 @@
|
||||
<div class="container">
|
||||
<div class="row" style="margin-top: 100px;">
|
||||
<div class="col-sm-offset-3 col-sm-6">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
Start ERPNext Demo
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<p>
|
||||
<input id="lead-email" type="email"
|
||||
class="form-control" placeholder="Your Email Id">
|
||||
</p>
|
||||
<p>
|
||||
<button type="submit" id="login_btn"
|
||||
class="btn btn-primary btn-large">Launch Demo</button>
|
||||
</p>
|
||||
<hr>
|
||||
<p class="text-muted small">Some functionality is disabled for the demo app. The demo data will be cleared regulary. To start your own ERPNext Trial, <a href="https://erpnext.com/pricing-and-signup">click here</a></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
</div>
|
||||
</div>
|
27
utilities/demo/demo-login.js
Normal file
27
utilities/demo/demo-login.js
Normal file
@ -0,0 +1,27 @@
|
||||
$(document).ready(function() {
|
||||
$(".navbar, footer, .banner, #user-tools").toggle(false);
|
||||
|
||||
$("#login_btn").click(function() {
|
||||
var me = this;
|
||||
$(this).html("Logging In...").attr("disabled", "disabled");
|
||||
wn.call({
|
||||
"method": "login",
|
||||
args: {
|
||||
usr: "demo@erpnext.com",
|
||||
pwd: "demo",
|
||||
lead_email: $("#lead-email").val(),
|
||||
},
|
||||
callback: function(r) {
|
||||
$(me).attr("disabled", false);
|
||||
if(r.exc) {
|
||||
alert("Error, please contact support@erpnext.com");
|
||||
} else {
|
||||
console.log("Logged In");
|
||||
window.location.href = "app.html";
|
||||
}
|
||||
}
|
||||
})
|
||||
return false;
|
||||
})
|
||||
.attr("disabled", false);
|
||||
})
|
13
utilities/demo/demo_control_panel.py
Normal file
13
utilities/demo/demo_control_panel.py
Normal file
@ -0,0 +1,13 @@
|
||||
|
||||
def on_login(self):
|
||||
from webnotes.utils import validate_email_add
|
||||
import conf
|
||||
if hasattr(conf, "demo_notify_url"):
|
||||
if webnotes.form_dict.lead_email and validate_email_add(webnotes.form_dict.lead_email):
|
||||
import requests
|
||||
response = requests.post(conf.demo_notify_url, data={
|
||||
"cmd":"website.helpers.contact.send_message",
|
||||
"subject":"Logged into Demo",
|
||||
"sender": webnotes.form_dict.lead_email,
|
||||
"message": "via demo.erpnext.com"
|
||||
})
|
Can't render this file because it has a wrong number of fields in line 2.
|
Before Width: | Height: | Size: 221 KiB After Width: | Height: | Size: 221 KiB |
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 40 KiB |
@ -19,9 +19,9 @@ company_abbr = "WP"
|
||||
country = "United States"
|
||||
currency = "USD"
|
||||
time_zone = "America/New York"
|
||||
start_date = '2010-01-01'
|
||||
start_date = '2013-01-01'
|
||||
bank_name = "Citibank"
|
||||
runs_for = 20
|
||||
runs_for = None
|
||||
prob = {
|
||||
"default": { "make": 0.6, "qty": (1,5) },
|
||||
"Sales Order": { "make": 0.4, "qty": (1,3) },
|
||||
@ -50,21 +50,24 @@ def setup():
|
||||
# make_opening_accounts()
|
||||
|
||||
def simulate():
|
||||
current_date = None
|
||||
for i in xrange(runs_for):
|
||||
if not current_date:
|
||||
# get last stock ledger posting date or use default
|
||||
last_posting = webnotes.conn.sql("""select max(posting_date) from `tabStock Ledger Entry`""")
|
||||
if last_posting[0][0]:
|
||||
current_date = webnotes.utils.add_days(last_posting[0][0], 1)
|
||||
else:
|
||||
current_date = webnotes.utils.getdate(start_date)
|
||||
else:
|
||||
current_date = webnotes.utils.add_days(current_date, 1)
|
||||
global runs_for
|
||||
current_date = webnotes.utils.getdate(start_date)
|
||||
|
||||
# continue?
|
||||
last_posting = webnotes.conn.sql("""select max(posting_date) from `tabStock Ledger Entry`""")
|
||||
if last_posting[0][0]:
|
||||
current_date = webnotes.utils.add_days(last_posting[0][0], 1)
|
||||
|
||||
# run till today
|
||||
if not runs_for:
|
||||
runs_for = webnotes.utils.date_diff(webnotes.utils.nowdate(), current_date)
|
||||
|
||||
for i in xrange(runs_for):
|
||||
print current_date.strftime("%Y-%m-%d")
|
||||
webnotes.utils.current_date = current_date
|
||||
|
||||
if current_date.weekday() in (5, 6):
|
||||
current_date = webnotes.utils.add_days(current_date, 1)
|
||||
continue
|
||||
|
||||
run_sales(current_date)
|
||||
@ -73,6 +76,8 @@ def simulate():
|
||||
run_stock(current_date)
|
||||
run_accounts(current_date)
|
||||
|
||||
current_date = webnotes.utils.add_days(current_date, 1)
|
||||
|
||||
def run_sales(current_date):
|
||||
if can_make("Quotation"):
|
||||
for i in xrange(how_many("Quotation")):
|
||||
@ -136,7 +141,7 @@ def run_stock(current_date):
|
||||
for po in list(set([r[0] for r in query_report.run(report)["result"] if r[0]!="Total"]))[:how_many("Purchase Receipt")]:
|
||||
pr = webnotes.bean(make_purchase_receipt(po))
|
||||
pr.doc.posting_date = current_date
|
||||
pr.doc.fiscal_year = "2010"
|
||||
pr.doc.fiscal_year = "2013"
|
||||
pr.insert()
|
||||
pr.submit()
|
||||
webnotes.conn.commit()
|
||||
@ -150,7 +155,7 @@ def run_stock(current_date):
|
||||
for so in list(set([r[0] for r in query_report.run(report)["result"] if r[0]!="Total"]))[:how_many("Delivery Note")]:
|
||||
dn = webnotes.bean(make_delivery_note(so))
|
||||
dn.doc.posting_date = current_date
|
||||
dn.doc.fiscal_year = "2010"
|
||||
dn.doc.fiscal_year = "2013"
|
||||
dn.insert()
|
||||
try:
|
||||
dn.submit()
|
||||
@ -173,7 +178,7 @@ def run_purchase(current_date):
|
||||
mr = webnotes.new_bean("Material Request")
|
||||
mr.doc.material_request_type = "Purchase"
|
||||
mr.doc.transaction_date = current_date
|
||||
mr.doc.fiscal_year = "2010"
|
||||
mr.doc.fiscal_year = "2013"
|
||||
mr.doclist.append({
|
||||
"doctype": "Material Request Item",
|
||||
"parentfield": "indent_details",
|
||||
@ -192,7 +197,7 @@ def run_purchase(current_date):
|
||||
if row[0] != "Total":
|
||||
sq = webnotes.bean(make_supplier_quotation(row[0]))
|
||||
sq.doc.transaction_date = current_date
|
||||
sq.doc.fiscal_year = "2010"
|
||||
sq.doc.fiscal_year = "2013"
|
||||
sq.insert()
|
||||
sq.submit()
|
||||
webnotes.conn.commit()
|
||||
@ -205,7 +210,7 @@ def run_purchase(current_date):
|
||||
if row[0] != "Total":
|
||||
po = webnotes.bean(make_purchase_order(row[0]))
|
||||
po.doc.transaction_date = current_date
|
||||
po.doc.fiscal_year = "2010"
|
||||
po.doc.fiscal_year = "2013"
|
||||
po.insert()
|
||||
po.submit()
|
||||
webnotes.conn.commit()
|
||||
@ -263,7 +268,7 @@ def make_stock_entry_from_pro(pro_id, purpose, current_date):
|
||||
|
||||
st = webnotes.bean(make_stock_entry(pro_id, purpose))
|
||||
st.doc.posting_date = current_date
|
||||
st.doc.fiscal_year = "2010"
|
||||
st.doc.fiscal_year = "2013"
|
||||
st.doc.expense_adjustment_account = "Stock in Hand - WP"
|
||||
try:
|
||||
st.insert()
|
||||
@ -282,7 +287,7 @@ def make_quotation(current_date):
|
||||
"customer": get_random("Customer"),
|
||||
"order_type": "Sales",
|
||||
"transaction_date": current_date,
|
||||
"fiscal_year": "2010"
|
||||
"fiscal_year": "2013"
|
||||
}])
|
||||
|
||||
add_random_children(b, {
|
||||
@ -349,8 +354,9 @@ def how_many(doctype):
|
||||
def install():
|
||||
print "Creating Fresh Database..."
|
||||
from webnotes.install_lib.install import Installer
|
||||
import conf
|
||||
inst = Installer('root')
|
||||
inst.import_from_db("demo", verbose = 1)
|
||||
inst.import_from_db(conf.demo_db_name, verbose = 1)
|
||||
|
||||
def complete_setup():
|
||||
print "Complete Setup..."
|
||||
@ -392,6 +398,7 @@ def make_bank_account():
|
||||
}).insert()
|
||||
|
||||
webnotes.set_value("Company", company, "default_bank_account", ba.doc.name)
|
||||
webnotes.conn.commit()
|
||||
|
||||
def import_data(dt, submit=False):
|
||||
if not isinstance(dt, (tuple, list)):
|
77
utilities/demo/make_erpnext_demo.py
Normal file
77
utilities/demo/make_erpnext_demo.py
Normal file
@ -0,0 +1,77 @@
|
||||
import webnotes, os
|
||||
|
||||
def make_demo_app():
|
||||
import utilities.demo.make_demo
|
||||
utilities.demo.make_demo.make(reset=True)
|
||||
|
||||
def make_demo_user():
|
||||
if webnotes.conn.exists("Profile", "demo@erpnext.com"):
|
||||
webnotes.delete_doc("Profile", "demo@erpnext.com")
|
||||
|
||||
p = webnotes.new_bean("Profile")
|
||||
p.doc.email = "demo@erpnext.com"
|
||||
p.doc.first_name = "Demo"
|
||||
p.doc.last_name = "User"
|
||||
p.doc.enabled = 1
|
||||
p.doc.user_type = "ERPNext Demo"
|
||||
p.doc.send_invite_email = 0
|
||||
p.doc.new_password = "demo"
|
||||
p.insert()
|
||||
|
||||
for role in ("Accounts Manager", "Analytics", "Expense Approver", "Accounts User",
|
||||
"Leave Approver", "Blogger", "Customer", "Sales Manager", "Employee", "Support Manager",
|
||||
"HR Manager", "HR User", "Maintenance Manager", "Maintenance User", "Material Manager",
|
||||
"Material Master Manager", "Material User", "Partner", "Manufacturing Manager",
|
||||
"Manufacturing User", "Projects User", "Purchase Manager", "Purchase Master Manager",
|
||||
"Purchase User", "Quality Manager", "Report Manager", "Sales Master Manager", "Sales User",
|
||||
"Supplier", "Support Team"):
|
||||
p.doclist.append({
|
||||
"doctype": "UserRole",
|
||||
"parentfield": "user_roles",
|
||||
"role": role
|
||||
})
|
||||
|
||||
p.save()
|
||||
webnotes.conn.commit()
|
||||
|
||||
def make_demo_login_page():
|
||||
webnotes.conn.set_value("Website Settings", None, "home_page", "")
|
||||
|
||||
webnotes.conn.sql("""delete from `tabWeb Page` where name='demo-login'""")
|
||||
p = webnotes.new_bean("Web Page")
|
||||
p.doc.title = "Demo Login"
|
||||
p.doc.published = 1
|
||||
p.doc.description = "ERPNext Demo Login"
|
||||
|
||||
with open(os.path.join(os.path.dirname(__file__), "demo-login.html"), "r") as dfile:
|
||||
p.doc.main_section = dfile.read()
|
||||
|
||||
p.doc.insert_code = 1
|
||||
with open(os.path.join(os.path.dirname(__file__), "demo-login.js"), "r") as dfile:
|
||||
p.doc.javascript = dfile.read()
|
||||
|
||||
p.doc.insert_style = 1
|
||||
with open(os.path.join(os.path.dirname(__file__), "demo-login.css"), "r") as dfile:
|
||||
p.doc.css = dfile.read()
|
||||
|
||||
p.insert()
|
||||
|
||||
webnotes.conn.set_value("Website Settings", None, "home_page", "demo-login")
|
||||
|
||||
webnotes.conn.commit()
|
||||
|
||||
def make_demo_on_login_script():
|
||||
webnotes.conn.sql("""delete from `tabCustom Script` where dt='Control Panel'""")
|
||||
s = webnotes.new_bean("Custom Script")
|
||||
s.doc.dt = "Control Panel"
|
||||
s.doc.script_type = "Server"
|
||||
with open(os.path.join(os.path.dirname(__file__), "demo_control_panel.py"), "r") as dfile:
|
||||
s.doc.script = dfile.read()
|
||||
|
||||
if __name__=="__main__":
|
||||
webnotes.connect()
|
||||
webnotes.mute_emails = 1
|
||||
make_demo_app()
|
||||
make_demo_user()
|
||||
make_demo_login_page()
|
||||
make_demo_on_login_script()
|
@ -4,6 +4,14 @@
|
||||
// update parent select
|
||||
|
||||
$.extend(cur_frm.cscript, {
|
||||
refresh: function(doc) {
|
||||
cur_frm.add_custom_button("Auto Build Website", function() {
|
||||
cur_frm.call({
|
||||
doc: cur_frm.doc,
|
||||
method: "make_website"
|
||||
})
|
||||
}, 'icon-magic')
|
||||
},
|
||||
onload_post_render: function(doc) {
|
||||
this.set_parent_label_options();
|
||||
},
|
||||
|
@ -14,6 +14,26 @@ class DocType:
|
||||
self.validate_top_bar_items()
|
||||
self.validate_footer_items()
|
||||
|
||||
def make_website(self):
|
||||
# set item pages
|
||||
for name in webnotes.conn.sql_list("""select name from tabItem where
|
||||
ifnull(show_in_website, 0)=0 and is_sales_item ='Yes' """):
|
||||
webnotes.msgprint("Setting 'Show in Website' for:" + name)
|
||||
item = webnotes.bean("Item", name)
|
||||
item.doc.show_in_website = 1
|
||||
item.doc.website_warehouse = item.doc.default_warehouse
|
||||
item.doc.website_image = item.doc.image
|
||||
item.save()
|
||||
|
||||
# set item group pages
|
||||
for name in webnotes.conn.sql_list("""select name from `tabItem Group` where
|
||||
ifnull(show_in_website, 0)=0 and exists (select name from tabItem where
|
||||
ifnull(show_in_website, 0)=1)"""):
|
||||
webnotes.msgprint("Setting 'Show in Website' for:" + name)
|
||||
item_group = webnotes.bean("Item Group", name)
|
||||
item_group.doc.show_in_website = 1
|
||||
item_group.save()
|
||||
|
||||
def validate_top_bar_items(self):
|
||||
"""validate url in top bar items"""
|
||||
for top_bar_item in self.doclist.get({"parentfield": "top_bar_items"}):
|
||||
|
Loading…
x
Reference in New Issue
Block a user