random time fix and other minor fixes
diff --git a/erpnext/demo/user/accounts.py b/erpnext/demo/user/accounts.py
index a12933b..1885504 100644
--- a/erpnext/demo/user/accounts.py
+++ b/erpnext/demo/user/accounts.py
@@ -56,7 +56,7 @@
if random.random() < 0.5:
make_payment_entries("Purchase Invoice", "Accounts Payable")
- if random.random() < 0.1:
+ if random.random() < 0.4:
#make payment request against sales invoice
sales_invoice_name = get_random("Sales Invoice", filters={"docstatus": 1})
if sales_invoice_name:
diff --git a/erpnext/demo/user/projects.py b/erpnext/demo/user/projects.py
index 9802447..ee87199 100644
--- a/erpnext/demo/user/projects.py
+++ b/erpnext/demo/user/projects.py
@@ -3,7 +3,7 @@
from __future__ import unicode_literals
-import frappe
+import frappe, erpnext
from frappe.utils import flt
from frappe.utils.make_random import get_random
from erpnext.projects.doctype.timesheet.test_timesheet import make_timesheet
@@ -19,7 +19,7 @@
def make_timesheet_for_projects(current_date ):
for data in frappe.get_all("Task", ["name", "project"], {"status": "Open", "exp_end_date": ("<", current_date)}):
employee = get_random("Employee")
- ts = make_timesheet(employee, simulate = True, billable = 1,
+ ts = make_timesheet(employee, simulate = True, billable = 1, company = erpnext.get_default_company(),
activity_type=get_random("Activity Type"), project=data.project, task =data.name)
if flt(ts.total_billable_amount) > 0.0:
diff --git a/erpnext/demo/user/purchase.py b/erpnext/demo/user/purchase.py
index a9a603c..4796bf3 100644
--- a/erpnext/demo/user/purchase.py
+++ b/erpnext/demo/user/purchase.py
@@ -3,7 +3,7 @@
from __future__ import unicode_literals
-import frappe, random
+import frappe, random, json
from frappe.utils.make_random import how_many, get_random
from frappe.desk import query_report
from erpnext.setup.utils import get_exchange_rate
@@ -16,14 +16,14 @@
def work():
frappe.set_user(frappe.db.get_global('demo_purchase_user'))
- if random.random() < 0.3:
+ if random.random() < 0.6:
report = "Items To Be Requested"
for row in query_report.run(report)["result"][:random.randint(1, 5)]:
item_code, qty = row[0], abs(row[-1])
mr = make_material_request(item_code, qty)
- if random.random() < 0.3:
+ if random.random() < 0.6:
for mr in frappe.get_all('Material Request',
filters={'material_request_type': 'Purchase', 'status': 'Open'},
limit=random.randint(1,6)):
@@ -36,7 +36,7 @@
rfq.submit()
# Make suppier quotation from RFQ against each supplier.
- if random.random() < 0.3:
+ if random.random() < 0.6:
for rfq in frappe.get_all('Request for Quotation',
filters={'status': 'Open'}, limit=random.randint(1, 6)):
if not frappe.get_all('Supplier Quotation',
@@ -59,7 +59,7 @@
exchange_rate = get_exchange_rate(party_account_currency, company_currency, args="for_buying")
# make supplier quotations
- if random.random() < 0.2:
+ if random.random() < 0.5:
from erpnext.stock.doctype.material_request.material_request import make_supplier_quotation
report = "Material Requests for which Supplier Quotations are not created"
@@ -89,7 +89,7 @@
po.submit()
frappe.db.commit()
- if random.random() < 0.2:
+ if random.random() < 0.5:
make_subcontract()
def make_material_request(item_code, qty):
@@ -129,6 +129,7 @@
po = frappe.new_doc("Purchase Order")
po.is_subcontracted = "Yes"
po.supplier = get_random("Supplier")
+ po.transaction_date = frappe.flags.current_date # added
po.schedule_date = frappe.utils.add_days(frappe.flags.current_date, 7)
item_code = get_random("Item", {"is_sub_contracted_item": 1})
@@ -150,7 +151,7 @@
make_material_request(po.items[0].item_code, po.items[0].qty)
# transfer material for sub-contract
- stock_entry = frappe.get_doc(make_rm_stock_entry(po.name, po.items[0].item_code))
+ stock_entry = frappe.get_doc(make_rm_stock_entry(po.name, frappe.as_json(po.items)))
stock_entry.from_warehouse = "Stores - WPL"
stock_entry.to_warehouse = "Supplier - WPL"
stock_entry.insert()
diff --git a/erpnext/demo/user/sales.py b/erpnext/demo/user/sales.py
index 65d7f55..304576a 100644
--- a/erpnext/demo/user/sales.py
+++ b/erpnext/demo/user/sales.py
@@ -12,12 +12,13 @@
def work():
frappe.set_user(frappe.db.get_global('demo_sales_user_2'))
- if random.random() < 0.5:
- for i in range(random.randint(1,7)):
+
+ for i in range(random.randint(1,7)):
+ if random.random() < 0.5:
make_opportunity()
- if random.random() < 0.5:
- for i in range(random.randint(1,3)):
+ for i in range(random.randint(1,3)):
+ if random.random() < 0.5:
make_quotation()
# lost quotations / inquiries
@@ -32,11 +33,11 @@
if opportunity and opportunity.status in ('Open', 'Replied'):
opportunity.declare_enquiry_lost('Did not ask')
- if random.random() < 0.3:
- for i in range(random.randint(1,3)):
+ for i in range(random.randint(1,3)):
+ if random.random() < 0.3:
make_sales_order()
- if random.random() < 0.1:
+ if random.random() < 0.5:
#make payment request against Sales Order
sales_order_name = get_random("Sales Order", filters={"docstatus": 1})
if sales_order_name:
@@ -115,8 +116,8 @@
def make_sales_order():
q = get_random("Quotation", {"status": "Submitted"})
if q:
- from erpnext.selling.doctype.quotation.quotation import make_sales_order
- so = frappe.get_doc(make_sales_order(q))
+ from erpnext.selling.doctype.quotation.quotation import make_sales_order as mso
+ so = frappe.get_doc(mso(q))
so.transaction_date = frappe.flags.current_date
so.delivery_date = frappe.utils.add_days(frappe.flags.current_date, 10)
so.insert()
diff --git a/erpnext/demo/user/stock.py b/erpnext/demo/user/stock.py
index a6b0e00..50257dc 100644
--- a/erpnext/demo/user/stock.py
+++ b/erpnext/demo/user/stock.py
@@ -3,7 +3,7 @@
from __future__ import print_function, unicode_literals
-import frappe, random
+import frappe, random, erpnext
from frappe.desk import query_report
from erpnext.stock.stock_ledger import NegativeStockError
from erpnext.stock.doctype.serial_no.serial_no import SerialNoRequiredError, SerialNoQtyError
@@ -45,7 +45,7 @@
# make purchase requests
# make delivery notes (if possible)
- if random.random() < 0.3:
+ if random.random() < 0.6:
from erpnext.selling.doctype.sales_order.sales_order import make_delivery_note
report = "Ordered Items To Be Delivered"
for so in list(set([r[0] for r in query_report.run(report)["result"]
@@ -68,9 +68,10 @@
from erpnext.stock.doctype.stock_reconciliation.stock_reconciliation \
import OpeningEntryAccountError, EmptyStockReconciliationItemsError
- if random.random() < 0.1:
+ if random.random() < 0.4:
stock_reco = frappe.new_doc("Stock Reconciliation")
stock_reco.posting_date = frappe.flags.current_date
+ stock_reco.company = erpnext.get_default_company()
stock_reco.get_items_for("Stores - WP")
if stock_reco.items:
for item in stock_reco.items:
@@ -87,7 +88,7 @@
def submit_draft_stock_entries():
from erpnext.stock.doctype.stock_entry.stock_entry import IncorrectValuationRateError, \
- DuplicateEntryForProductionOrderError, OperationsNotCompleteError
+ DuplicateEntryForWorkOrderError, OperationsNotCompleteError
# try posting older drafts (if exists)
frappe.db.commit()
@@ -98,7 +99,7 @@
ste.save()
ste.submit()
frappe.db.commit()
- except (NegativeStockError, IncorrectValuationRateError, DuplicateEntryForProductionOrderError,
+ except (NegativeStockError, IncorrectValuationRateError, DuplicateEntryForWorkOrderError,
OperationsNotCompleteError):
frappe.db.rollback()