def make_quotation(current_date): # get open opportunites opportunity = get_random("Opportunity", {"status": "Open"}) if opportunity: from erpnext.crm.doctype.opportunity.opportunity import make_quotation qtn = frappe.get_doc(make_quotation(opportunity)) qtn.insert() frappe.db.commit() qtn.submit() frappe.db.commit() else: # make new directly qtn = frappe.get_doc({ "creation": current_date, "doctype": "Quotation", "quotation_to": "Customer", "customer": get_random("Customer"), "order_type": "Sales", "transaction_date": current_date, "fiscal_year": cstr(current_date.year) }) add_random_children(qtn, "items", rows=3, randomize = { "qty": (1, 5), "item_code": ("Item", {"is_sales_item": "Yes", "ifnull(has_variants,0)": "0"}) }, unique="item_code") qtn.insert() frappe.db.commit() qtn.submit() frappe.db.commit()
def make_opportunity(current_date): b = frappe.get_doc({ "creation": current_date, "doctype": "Opportunity", "enquiry_from": "Customer", "customer": get_random("Customer"), "enquiry_type": "Sales", "transaction_date": current_date, "fiscal_year": cstr(current_date.year) }) add_random_children(b, "items", rows=4, randomize = { "qty": (1, 5), "item_code": ("Item", {"is_sales_item": "Yes", "ifnull(has_variants,0)": "0"}) }, unique="item_code") b.insert() frappe.db.commit()