mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-13 02:01:21 +00:00
[minor] wnf refactor, fixes in demo
This commit is contained in:
@@ -31,7 +31,7 @@ class DocType:
|
|||||||
if not webnotes.conn.get_value("Account", {"account_type": "Warehouse",
|
if not webnotes.conn.get_value("Account", {"account_type": "Warehouse",
|
||||||
"master_name": self.doc.name}) and not webnotes.conn.get_value("Account",
|
"master_name": self.doc.name}) and not webnotes.conn.get_value("Account",
|
||||||
{"account_name": self.doc.warehouse_name}):
|
{"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}):
|
{"warehouse": self.doc.name}):
|
||||||
self.validate_parent_account()
|
self.validate_parent_account()
|
||||||
ac_bean = webnotes.bean({
|
ac_bean = webnotes.bean({
|
||||||
|
|||||||
@@ -34,17 +34,20 @@ def make(reset=False, simulate=True):
|
|||||||
webnotes.mute_emails = True
|
webnotes.mute_emails = True
|
||||||
webnotes.rollback_on_exception = 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:
|
if reset:
|
||||||
setup()
|
setup()
|
||||||
else:
|
else:
|
||||||
webnotes.connect()
|
webnotes.connect(db_name=webnotes.conf.demo_db_name)
|
||||||
|
|
||||||
if simulate:
|
if simulate:
|
||||||
_simulate()
|
_simulate()
|
||||||
|
|
||||||
def setup():
|
def setup():
|
||||||
install()
|
install()
|
||||||
webnotes.connect()
|
webnotes.connect(db_name=webnotes.conf.demo_db_name)
|
||||||
complete_setup()
|
complete_setup()
|
||||||
make_customers_suppliers_contacts()
|
make_customers_suppliers_contacts()
|
||||||
make_items()
|
make_items()
|
||||||
@@ -142,14 +145,17 @@ def run_stock(current_date):
|
|||||||
# make purchase requests
|
# make purchase requests
|
||||||
if can_make("Purchase Receipt"):
|
if can_make("Purchase Receipt"):
|
||||||
from buying.doctype.purchase_order.purchase_order import 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"
|
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")]:
|
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 = webnotes.bean(make_purchase_receipt(po))
|
||||||
pr.doc.posting_date = current_date
|
pr.doc.posting_date = current_date
|
||||||
pr.doc.fiscal_year = "2013"
|
pr.doc.fiscal_year = "2013"
|
||||||
pr.insert()
|
pr.insert()
|
||||||
pr.submit()
|
try:
|
||||||
webnotes.conn.commit()
|
pr.submit()
|
||||||
|
webnotes.conn.commit()
|
||||||
|
except NegativeStockError: pass
|
||||||
|
|
||||||
# make delivery notes (if possible)
|
# make delivery notes (if possible)
|
||||||
if can_make("Delivery Note"):
|
if can_make("Delivery Note"):
|
||||||
@@ -363,7 +369,7 @@ def install():
|
|||||||
from webnotes.install_lib.install import Installer
|
from webnotes.install_lib.install import Installer
|
||||||
from webnotes import conf
|
from webnotes import conf
|
||||||
inst = Installer('root')
|
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():
|
def complete_setup():
|
||||||
print "Complete Setup..."
|
print "Complete Setup..."
|
||||||
|
|||||||
@@ -7,7 +7,9 @@ import utilities.demo.make_demo
|
|||||||
|
|
||||||
def make_demo_app(site=None):
|
def make_demo_app(site=None):
|
||||||
webnotes.mute_emails = 1
|
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)
|
utilities.demo.make_demo.make(reset=True, simulate=False)
|
||||||
# setup demo user etc so that the site it up faster, while the data loads
|
# setup demo user etc so that the site it up faster, while the data loads
|
||||||
make_demo_user()
|
make_demo_user()
|
||||||
@@ -116,4 +118,6 @@ def make_demo_on_login_script():
|
|||||||
webnotes.conn.commit()
|
webnotes.conn.commit()
|
||||||
|
|
||||||
if __name__=="__main__":
|
if __name__=="__main__":
|
||||||
make_demo_app()
|
import sys
|
||||||
|
site = sys.argv[1:]
|
||||||
|
make_demo_app(site=site and site[0] or None)
|
||||||
|
|||||||
Reference in New Issue
Block a user