[minor] wnf refactor, fixes in demo

This commit is contained in:
Anand Doshi 2013-09-26 15:56:54 +05:30
parent 5b004ff8a7
commit f879a9dc2e
3 changed files with 18 additions and 8 deletions

View File

@ -31,7 +31,7 @@ class DocType:
if not webnotes.conn.get_value("Account", {"account_type": "Warehouse",
"master_name": self.doc.name}) and not webnotes.conn.get_value("Account",
{"account_name": self.doc.warehouse_name}):
if self.doc.__islocal or not webnotes.conn.get_value("Stock Ledger Entry",
if self.doc.fields.get("__islocal") or not webnotes.conn.get_value("Stock Ledger Entry",
{"warehouse": self.doc.name}):
self.validate_parent_account()
ac_bean = webnotes.bean({

View File

@ -34,17 +34,20 @@ def make(reset=False, simulate=True):
webnotes.mute_emails = True
webnotes.rollback_on_exception = True
if not webnotes.conf.demo_db_name:
raise Exception("conf.py does not have demo_db_name")
if reset:
setup()
else:
webnotes.connect()
webnotes.connect(db_name=webnotes.conf.demo_db_name)
if simulate:
_simulate()
def setup():
install()
webnotes.connect()
webnotes.connect(db_name=webnotes.conf.demo_db_name)
complete_setup()
make_customers_suppliers_contacts()
make_items()
@ -142,14 +145,17 @@ def run_stock(current_date):
# make purchase requests
if can_make("Purchase Receipt"):
from buying.doctype.purchase_order.purchase_order import make_purchase_receipt
from stock.stock_ledger import NegativeStockError
report = "Purchase Order Items To Be Received"
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 = "2013"
pr.insert()
pr.submit()
webnotes.conn.commit()
try:
pr.submit()
webnotes.conn.commit()
except NegativeStockError: pass
# make delivery notes (if possible)
if can_make("Delivery Note"):
@ -363,7 +369,7 @@ def install():
from webnotes.install_lib.install import Installer
from webnotes import conf
inst = Installer('root')
inst.import_from_db(conf.demo_db_name, verbose = 1)
inst.install(conf.demo_db_name, verbose=1, force=1)
def complete_setup():
print "Complete Setup..."

View File

@ -7,7 +7,9 @@ import utilities.demo.make_demo
def make_demo_app(site=None):
webnotes.mute_emails = 1
webnotes.connect(site)
webnotes.init(site=site)
webnotes.connect(db_name=webnotes.conf.demo_db_name, site=site)
utilities.demo.make_demo.make(reset=True, simulate=False)
# setup demo user etc so that the site it up faster, while the data loads
make_demo_user()
@ -116,4 +118,6 @@ def make_demo_on_login_script():
webnotes.conn.commit()
if __name__=="__main__":
make_demo_app()
import sys
site = sys.argv[1:]
make_demo_app(site=site and site[0] or None)