[purchase order] tests pass
diff --git a/accounts/doctype/purchase_invoice/purchase_invoice.py b/accounts/doctype/purchase_invoice/purchase_invoice.py
index 3060a1e..8d646ba 100644
--- a/accounts/doctype/purchase_invoice/purchase_invoice.py
+++ b/accounts/doctype/purchase_invoice/purchase_invoice.py
@@ -244,7 +244,7 @@
raise Exception , " Validation Error "
def validate_reference_value(self):
- # pass
+ pass
# Validate PO and PR
# -------------------
diff --git a/buying/doctype/purchase_order/purchase_order.py b/buying/doctype/purchase_order/purchase_order.py
index 0b3f317..4972f66 100644
--- a/buying/doctype/purchase_order/purchase_order.py
+++ b/buying/doctype/purchase_order/purchase_order.py
@@ -234,7 +234,6 @@
def make_purchase_invoice(source_name, target_doclist=None):
from webnotes.model.mapper import get_mapped_doclist
-
def set_missing_values(source, target):
bean = webnotes.bean(target)
bean.run_method("set_missing_values")
diff --git a/buying/doctype/purchase_order/test_purchase_order.py b/buying/doctype/purchase_order/test_purchase_order.py
index 85420d8..e70de97 100644
--- a/buying/doctype/purchase_order/test_purchase_order.py
+++ b/buying/doctype/purchase_order/test_purchase_order.py
@@ -32,10 +32,13 @@
po = webnotes.bean("Purchase Order", po.doc.name)
po.submit()
pr = make_purchase_receipt(po.doc.name)
+ pr[0]["supplier_warehouse"] = "_Test Warehouse 1"
self.assertEquals(pr[0]["doctype"], "Purchase Receipt")
self.assertEquals(len(pr), len(test_records[0]))
+ webnotes.bean(pr).insert()
+
def test_make_purchase_invocie(self):
from buying.doctype.purchase_order.purchase_order import make_purchase_invoice
@@ -50,10 +53,12 @@
self.assertEquals(pi[0]["doctype"], "Purchase Invoice")
self.assertEquals(len(pi), len(test_records[0]))
+
+ webnotes.bean(pi).insert()
def test_subcontracting(self):
po = webnotes.bean(copy=test_records[0])
- po.insert()
+ po.insert()
self.assertEquals(len(po.doclist.get({"parentfield": "po_raw_material_details"})), 2)
def test_warehouse_company_validation(self):
diff --git a/controllers/buying_controller.py b/controllers/buying_controller.py
index 03f7726..a44ceba 100644
--- a/controllers/buying_controller.py
+++ b/controllers/buying_controller.py
@@ -52,9 +52,11 @@
self.doc.fields[fieldname] = val
self.set_missing_item_details(get_item_details)
-
+
def set_supplier_defaults(self):
- self.doc.fields.update(self.get_default_supplier_address(self.doc.fields))
+ for fieldname, val in self.get_default_address_and_contact("supplier").items():
+ if self.meta.get_field(fieldname):
+ self.doc.fields[fieldname] = val
def get_purchase_tax_details(self):
self.doclist = self.doc.clear_table(self.doclist, "purchase_tax_details")
diff --git a/stock/doctype/purchase_receipt/purchase_receipt.py b/stock/doctype/purchase_receipt/purchase_receipt.py
index 3db31eb..878dfe8 100644
--- a/stock/doctype/purchase_receipt/purchase_receipt.py
+++ b/stock/doctype/purchase_receipt/purchase_receipt.py
@@ -68,6 +68,12 @@
msgprint("Rejected Warehouse is necessary if there are rejections.")
raise Exception
+ if not flt(d.qty) and flt(d.rejected_qty):
+ d.qty = flt(d.received_qty) - flt(d.rejected_qty)
+
+ elif not flt(d.rejected_qty):
+ d.rejected_qty = flt(d.received_qty) - flt(d.qty)
+
# Check Received Qty = Accepted Qty + Rejected Qty
if ((flt(d.qty) + flt(d.rejected_qty)) != flt(d.received_qty)):