def run_purchase(current_date): # make material requests for purchase items that have negative projected qtys if can_make("Material Request"): report = "Items To Be Requested" for row in query_report.run( report)["result"][:how_many("Material Request")]: mr = webnotes.new_bean("Material Request") mr.doc.material_request_type = "Purchase" mr.doc.transaction_date = current_date mr.doc.fiscal_year = current_date.year mr.doclist.append({ "doctype": "Material Request Item", "parentfield": "indent_details", "schedule_date": webnotes.utils.add_days(current_date, 7), "item_code": row[0], "qty": -row[-1] }) mr.insert() mr.submit() # make supplier quotations if can_make("Supplier Quotation"): from stock.doctype.material_request.material_request import make_supplier_quotation report = "Material Requests for which Supplier Quotations are not created" for row in query_report.run( report)["result"][:how_many("Supplier Quotation")]: if row[0] != "Total": sq = webnotes.bean(make_supplier_quotation(row[0])) sq.doc.transaction_date = current_date sq.doc.fiscal_year = current_date.year sq.insert() sq.submit() webnotes.conn.commit() # make purchase orders if can_make("Purchase Order"): from stock.doctype.material_request.material_request import make_purchase_order report = "Requested Items To Be Ordered" for row in query_report.run( report)["result"][:how_many("Purchase Order")]: if row[0] != "Total": po = webnotes.bean(make_purchase_order(row[0])) po.doc.transaction_date = current_date po.doc.fiscal_year = current_date.year po.insert() po.submit() webnotes.conn.commit()
def test_make_supplier_quotation(self): from stock.doctype.material_request.material_request import make_supplier_quotation mr = webnotes.bean(copy=test_records[0]).insert() self.assertRaises(webnotes.ValidationError, make_supplier_quotation, mr.doc.name) mr = webnotes.bean("Material Request", mr.doc.name) mr.submit() sq = make_supplier_quotation(mr.doc.name) self.assertEquals(sq[0]["doctype"], "Supplier Quotation") self.assertEquals(len(sq), len(mr.doclist))
def run_purchase(current_date): # make material requests for purchase items that have negative projected qtys if can_make("Material Request"): report = "Items To Be Requested" for row in query_report.run(report)["result"][:how_many("Material Request")]: mr = webnotes.new_bean("Material Request") mr.doc.material_request_type = "Purchase" mr.doc.transaction_date = current_date mr.doc.fiscal_year = "2013" mr.doclist.append({ "doctype": "Material Request Item", "parentfield": "indent_details", "schedule_date": webnotes.utils.add_days(current_date, 7), "item_code": row[0], "qty": -row[-1] }) mr.insert() mr.submit() # make supplier quotations if can_make("Supplier Quotation"): from stock.doctype.material_request.material_request import make_supplier_quotation report = "Material Requests for which Supplier Quotations are not created" for row in query_report.run(report)["result"][:how_many("Supplier Quotation")]: if row[0] != "Total": sq = webnotes.bean(make_supplier_quotation(row[0])) sq.doc.transaction_date = current_date sq.doc.fiscal_year = "2013" sq.insert() sq.submit() webnotes.conn.commit() # make purchase orders if can_make("Purchase Order"): from stock.doctype.material_request.material_request import make_purchase_order report = "Requested Items To Be Ordered" for row in query_report.run(report)["result"][:how_many("Purchase Order")]: if row[0] != "Total": po = webnotes.bean(make_purchase_order(row[0])) po.doc.transaction_date = current_date po.doc.fiscal_year = "2013" po.insert() po.submit() webnotes.conn.commit()