diff --git a/stock/doctype/warehouse/warehouse.py b/stock/doctype/warehouse/warehouse.py index 1494428549..faf9b04e00 100644 --- a/stock/doctype/warehouse/warehouse.py +++ b/stock/doctype/warehouse/warehouse.py @@ -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({ diff --git a/utilities/demo/make_demo.py b/utilities/demo/make_demo.py index 2d2d07e0ea..6c6ccab4df 100644 --- a/utilities/demo/make_demo.py +++ b/utilities/demo/make_demo.py @@ -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..." diff --git a/utilities/demo/make_erpnext_demo.py b/utilities/demo/make_erpnext_demo.py index 4a72e4b589..50c66a3233 100644 --- a/utilities/demo/make_erpnext_demo.py +++ b/utilities/demo/make_erpnext_demo.py @@ -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)