diff --git a/erpnext/demo/user/accounts.py b/erpnext/demo/user/accounts.py index 18855041ed..6206dfd2d0 100644 --- a/erpnext/demo/user/accounts.py +++ b/erpnext/demo/user/accounts.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals +import erpnext import frappe import random from frappe.utils import random_string @@ -72,8 +73,10 @@ def work(): make_pos_invoice() def make_payment_entries(ref_doctype, report): - outstanding_invoices = list(set([r[3] for r in query_report.run(report, - {"report_date": frappe.flags.current_date })["result"] if r[2]==ref_doctype])) + outstanding_invoices = list(set([r[3] for r in query_report.run(report, { + "report_date": frappe.flags.current_date, + "company": erpnext.get_default_company() + })["result"] if r[2]==ref_doctype])) # make Payment Entry for inv in outstanding_invoices[:random.randint(1, 2)]: diff --git a/erpnext/demo/user/manufacturing.py b/erpnext/demo/user/manufacturing.py index a28d061f38..bece0798fa 100644 --- a/erpnext/demo/user/manufacturing.py +++ b/erpnext/demo/user/manufacturing.py @@ -102,10 +102,18 @@ def submit_job_cards(): for operation in work_order.operations: job = job_map[operation.operation] - job.actual_start_date = start_date + job_time_log = frappe.new_doc("Job Card Time Log") + job_time_log.from_time = start_date minutes = operation.get("time_in_mins") - random_minutes = random.randint(int(minutes/2), minutes) - job.actual_end_date = job.actual_start_date + timedelta(minutes=random_minutes) - start_date = job.actual_end_date - job.save() + job_time_log.time_in_mins = random.randint(int(minutes/2), minutes) + job_time_log.to_time = job_time_log.from_time + \ + timedelta(minutes=job_time_log.time_in_mins) + job_time_log.parent = job.name + job_time_log.parenttype = 'Job Card' + job_time_log.parentfield = 'time_logs' + job_time_log.completed_qty = work_order.qty + job_time_log.save(ignore_permissions=True) + job.time_logs.append(job_time_log) + job.save(ignore_permissions=True) job.submit() + start_date = job_time_log.to_time diff --git a/erpnext/demo/user/sales.py b/erpnext/demo/user/sales.py index 69ba9007a6..d4b55e8e2c 100644 --- a/erpnext/demo/user/sales.py +++ b/erpnext/demo/user/sales.py @@ -21,17 +21,26 @@ def work(domain="Manufacturing"): if random.random() < 0.5: make_quotation(domain) + try: + lost_reason = frappe.get_doc({ + "doctype": "Opportunity Lost Reason", + "lost_reason": "Did not ask" + }) + lost_reason.save(ignore_permissions=True) + except frappe.exceptions.DuplicateEntryError: + pass + # lost quotations / inquiries if random.random() < 0.3: for i in range(random.randint(1,3)): quotation = get_random('Quotation', doc=True) if quotation and quotation.status == 'Submitted': - quotation.declare_order_lost('Did not ask') + quotation.declare_order_lost([{'lost_reason': 'Did not ask'}]) for i in range(random.randint(1,3)): opportunity = get_random('Opportunity', doc=True) if opportunity and opportunity.status in ('Open', 'Replied'): - opportunity.declare_enquiry_lost('Did not ask') + opportunity.declare_enquiry_lost([{'lost_reason': 'Did not ask'}]) for i in range(random.randint(1,3)): if random.random() < 0.6: diff --git a/erpnext/demo/user/stock.py b/erpnext/demo/user/stock.py index 60b1edcac5..f95a6b8331 100644 --- a/erpnext/demo/user/stock.py +++ b/erpnext/demo/user/stock.py @@ -73,13 +73,13 @@ def make_stock_reconciliation(): 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") + stock_reco.get_items_for("Stores - WPL") if stock_reco.items: for item in stock_reco.items: if item.qty: item.qty = item.qty - round(random.randint(1, item.qty)) try: - stock_reco.insert() + stock_reco.insert(ignore_permissions=True) stock_reco.submit() frappe.db.commit() except OpeningEntryAccountError: