fix(demo): make demo work again
definitely not a maga rebranding. * import erpnext and set default company for accounts * replace job card start/end date with job card time log * create a doc for lost_reason * pass opportunity/quotation lost_reason as a list of dicts * fix company in stock reconciliation Signed-off-by: Chinmay Pai <chinmaydpai@gmail.com>
This commit is contained in:
parent
fa626bd3ab
commit
b503896594
@ -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)]:
|
||||
|
@ -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
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user