diff --git a/buying/doctype/purchase_order/purchase_order.py b/buying/doctype/purchase_order/purchase_order.py index 169dcaaef7..0b3f317cc5 100644 --- a/buying/doctype/purchase_order/purchase_order.py +++ b/buying/doctype/purchase_order/purchase_order.py @@ -44,23 +44,13 @@ class DocType(BuyingController): utilities.validate_status(self.doc.status, ["Draft", "Submitted", "Stopped", "Cancelled"]) - # Step 2:=> get Purchase Common Obj pc_obj = get_obj(dt='Purchase Common') - - - # Step 4:=> validate for items pc_obj.validate_for_items(self) - - # Get po date pc_obj.get_prevdoc_date(self) - - # validate_doc + self.validate_doc(pc_obj) - - # Check for stopped status self.check_for_stopped_status(pc_obj) - - # sub-contracting + self.validate_for_subcontracting() self.update_raw_materials_supplied("po_raw_material_details") diff --git a/buying/doctype/supplier_quotation/test_supplier_quotation.py b/buying/doctype/supplier_quotation/test_supplier_quotation.py index 0210b7fdc8..7e772cc4d7 100644 --- a/buying/doctype/supplier_quotation/test_supplier_quotation.py +++ b/buying/doctype/supplier_quotation/test_supplier_quotation.py @@ -36,6 +36,8 @@ class TestPurchaseOrder(unittest.TestCase): self.assertEquals(po[0]["doctype"], "Purchase Order") self.assertEquals(len(po), len(sq.doclist)) + webnotes.bean(po).insert() + test_records = [ [ { @@ -45,7 +47,7 @@ test_records = [ "doctype": "Supplier Quotation", "fiscal_year": "_Test Fiscal Year 2013", "transaction_date": "2013-02-12", - "is_subcontracted": "Yes", + "is_subcontracted": "No", "supplier": "_Test Supplier", "supplier_name": "_Test Supplier", "net_total": 5000.0, diff --git a/controllers/buying_controller.py b/controllers/buying_controller.py index e58eb03ca9..03f7726aa2 100644 --- a/controllers/buying_controller.py +++ b/controllers/buying_controller.py @@ -34,6 +34,9 @@ class BuyingController(StockController): def validate(self): super(BuyingController, self).validate() + if self.doc.supplier and not self.doc.supplier_name: + self.doc.supplier_name = webnotes.conn.get_value("Supplier", + self.doc.supplier, "supplier_name") self.validate_stock_or_nonstock_items() self.validate_warehouse_belongs_to_company() @@ -47,7 +50,7 @@ class BuyingController(StockController): for fieldname, val in self.get_default_address_and_contact("supplier").items(): if not self.doc.fields.get(fieldname) and self.meta.get_field(fieldname): self.doc.fields[fieldname] = val - + self.set_missing_item_details(get_item_details) def set_supplier_defaults(self): diff --git a/stock/doctype/material_request/test_material_request.py b/stock/doctype/material_request/test_material_request.py index fabcb40bd5..0efc3b0025 100644 --- a/stock/doctype/material_request/test_material_request.py +++ b/stock/doctype/material_request/test_material_request.py @@ -6,6 +6,9 @@ import webnotes, unittest from webnotes.utils import flt class TestMaterialRequest(unittest.TestCase): + def setUp(self): + webnotes.defaults.set_global_default("auto_inventory_accounting", 0) + def test_make_purchase_order(self): from stock.doctype.material_request.material_request import make_purchase_order @@ -118,6 +121,7 @@ class TestMaterialRequest(unittest.TestCase): # map a purchase order from stock.doctype.material_request.material_request import make_purchase_order po_doclist = make_purchase_order(mr.doc.name) + po_doclist[0].supplier = "_Test Supplier" po_doclist[1].qty = 27.0 po_doclist[2].qty = 1.5