mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-26 00:14:50 +00:00
[bom] [production] Cleaned up BOM, Production Planning Tool, Progress in Demo Builder
This commit is contained in:
@@ -8,10 +8,12 @@ import random
|
||||
webnotes.session = webnotes._dict({"user":"Administrator"})
|
||||
from core.page.data_import_tool.data_import_tool import upload
|
||||
|
||||
company = "Wind Power LLC"
|
||||
start_date = '2010-01-01'
|
||||
runs_for = 100
|
||||
prob = {
|
||||
"Quotation": 0.5
|
||||
"Quotation": { "make": 0.5, "qty": (1,3) },
|
||||
"Sales Order": { "make": 0.5, "qty": (1,2) }
|
||||
}
|
||||
|
||||
def make():
|
||||
@@ -20,9 +22,7 @@ def make():
|
||||
webnotes.mute_emails = True
|
||||
|
||||
# setup()
|
||||
# simulate()
|
||||
make_quotation("2010-01-01")
|
||||
webnotes.conn.commit()
|
||||
simulate()
|
||||
|
||||
def setup():
|
||||
install()
|
||||
@@ -30,13 +30,13 @@ def setup():
|
||||
make_items()
|
||||
make_customers_suppliers_contacts()
|
||||
make_users_and_employees()
|
||||
# make_bom()
|
||||
# make_opening_stock()
|
||||
# make_opening_accounts()
|
||||
|
||||
def simulate():
|
||||
current_date = None
|
||||
for i in xrange(runs_for):
|
||||
print i
|
||||
if not current_date:
|
||||
current_date = webnotes.utils.getdate(start_date)
|
||||
else:
|
||||
@@ -46,14 +46,34 @@ def simulate():
|
||||
continue
|
||||
|
||||
run_sales(current_date)
|
||||
|
||||
webnotes.conn.commit()
|
||||
run_purchase(current_date)
|
||||
run_manufacturing(current_date)
|
||||
|
||||
webnotes.conn.commit()
|
||||
|
||||
def run_sales(current_date):
|
||||
if random.random() < prob["Quotation"]:
|
||||
make_quotation(current_date)
|
||||
|
||||
if random.random() < prob["Quotation"]["make"]:
|
||||
for i in xrange(random.randrange(*prob["Quotation"]["qty"])):
|
||||
make_quotation(current_date)
|
||||
|
||||
if random.random() < prob["Sales Order"]["make"]:
|
||||
for i in xrange(random.randrange(*prob["Sales Order"]["qty"])):
|
||||
make_sales_order(current_date)
|
||||
|
||||
def run_purchase(current_date):
|
||||
pass
|
||||
|
||||
def run_manufacturing(current_date):
|
||||
ppt = webnotes.bean("Production Planning Tool", "Production Planning Tool")
|
||||
ppt.doc.company = company
|
||||
ppt.doc.use_multi_level_bom = 1
|
||||
ppt.doc.purchase_request_for_warehouse = "Stores - WP"
|
||||
ppt.run_method("get_open_sales_orders")
|
||||
ppt.run_method("get_items_from_so")
|
||||
ppt.run_method("get_items_from_so")
|
||||
ppt.run_method("raise_production_order")
|
||||
ppt.run_method("raise_purchase_request")
|
||||
|
||||
def make_quotation(current_date):
|
||||
b = webnotes.bean([{
|
||||
"creation": current_date,
|
||||
@@ -75,7 +95,16 @@ def make_quotation(current_date):
|
||||
}, unique="item_code")
|
||||
|
||||
b.insert()
|
||||
print b.doc.name
|
||||
b.submit()
|
||||
|
||||
def make_sales_order(current_date):
|
||||
q = get_random("Quotation", {"status": "Submitted"})
|
||||
from selling.doctype.quotation.quotation import make_sales_order
|
||||
so = webnotes.bean(make_sales_order(q))
|
||||
so.doc.transaction_date = current_date
|
||||
so.doc.delivery_date = webnotes.utils.add_days(current_date, 10)
|
||||
so.insert()
|
||||
so.submit()
|
||||
|
||||
def add_random_children(bean, template, rows, randomize, unique=None):
|
||||
for i in xrange(random.randrange(1, rows)):
|
||||
@@ -92,8 +121,6 @@ def add_random_children(bean, template, rows, randomize, unique=None):
|
||||
else:
|
||||
bean.doclist.append(d)
|
||||
|
||||
|
||||
|
||||
def get_random(doctype, filters=None):
|
||||
condition = []
|
||||
if filters:
|
||||
@@ -108,7 +135,7 @@ def get_random(doctype, filters=None):
|
||||
order by RAND() limit 0,1""" % (doctype, condition))[0][0]
|
||||
|
||||
return out
|
||||
|
||||
|
||||
def install():
|
||||
print "Creating Fresh Database..."
|
||||
from webnotes.install_lib.install import Installer
|
||||
@@ -122,57 +149,35 @@ def complete_setup():
|
||||
"last_name": "User",
|
||||
"fy_start": "1st Jan",
|
||||
"industry": "Manufacturing",
|
||||
"company_name": "Wind Power LLC",
|
||||
"company_name": company,
|
||||
"company_abbr": "WP",
|
||||
"currency": "USD",
|
||||
"timezone": "America/New York",
|
||||
"country": "United States"
|
||||
})
|
||||
|
||||
print "Importing Fiscal Years..."
|
||||
webnotes.uploaded_file = os.path.join(os.path.dirname(__file__), "demo_docs", "Fiscal_Year.csv")
|
||||
upload()
|
||||
|
||||
import_data("Fiscal_Year")
|
||||
|
||||
def make_items():
|
||||
print "Importing Items..."
|
||||
webnotes.uploaded_file = os.path.join(os.path.dirname(__file__), "demo_docs", "Item.csv")
|
||||
upload()
|
||||
print "Importing Item Prices..."
|
||||
webnotes.uploaded_file = os.path.join(os.path.dirname(__file__), "demo_docs", "Item_Price.csv")
|
||||
upload()
|
||||
import_data(["Item", "Item_Price", "BOM"])
|
||||
|
||||
def make_customers_suppliers_contacts():
|
||||
print "Importing Customers..."
|
||||
webnotes.uploaded_file = os.path.join(os.path.dirname(__file__), "demo_docs", "Customer.csv")
|
||||
upload()
|
||||
print "Importing Suppliers..."
|
||||
webnotes.uploaded_file = os.path.join(os.path.dirname(__file__), "demo_docs", "Supplier.csv")
|
||||
upload()
|
||||
print "Importing Contacts..."
|
||||
webnotes.uploaded_file = os.path.join(os.path.dirname(__file__), "demo_docs", "Contact.csv")
|
||||
upload()
|
||||
print "Importing Address..."
|
||||
webnotes.uploaded_file = os.path.join(os.path.dirname(__file__), "demo_docs", "Address.csv")
|
||||
upload()
|
||||
print "Importing Lead..."
|
||||
webnotes.uploaded_file = os.path.join(os.path.dirname(__file__), "demo_docs", "Lead.csv")
|
||||
upload()
|
||||
import_data(["Customer", "Supplier", "Contact", "Address", "Lead"])
|
||||
|
||||
def make_users_and_employees():
|
||||
print "Importing Profile..."
|
||||
webnotes.uploaded_file = os.path.join(os.path.dirname(__file__), "demo_docs", "Profile.csv")
|
||||
upload()
|
||||
webnotes.conn.set_value("HR Settings", None, "emp_created_by", "Naming Series")
|
||||
webnotes.conn.commit()
|
||||
|
||||
print "Importing Employee..."
|
||||
webnotes.uploaded_file = os.path.join(os.path.dirname(__file__), "demo_docs", "Employee.csv")
|
||||
upload()
|
||||
|
||||
print "Importing Salary Structure..."
|
||||
webnotes.uploaded_file = os.path.join(os.path.dirname(__file__), "demo_docs", "Salary_Structure.csv")
|
||||
upload()
|
||||
import_data(["Profile", "Employee", "Salary_Structure"])
|
||||
|
||||
def import_data(dt):
|
||||
if not isinstance(dt, (tuple, list)):
|
||||
dt = [dt]
|
||||
|
||||
for doctype in dt:
|
||||
print "Importing", doctype.replace("_", " "), "..."
|
||||
webnotes.uploaded_file = os.path.join(os.path.dirname(__file__), "demo_docs", doctype+".csv")
|
||||
upload()
|
||||
|
||||
if __name__=="__main__":
|
||||
make()
|
||||
Reference in New Issue
Block a user