test-cases added
This commit is contained in:
parent
67e9081bbf
commit
f9ced8f28f
@ -293,22 +293,19 @@ def make_supplier_quotation(source_name, target_doc=None):
|
||||
|
||||
@frappe.whitelist()
|
||||
def make_stock_entry(source_name, target_doc=None):
|
||||
|
||||
obj = frappe.get_doc("Material Request", source_name)
|
||||
|
||||
def update_item(obj, target, source_parent):
|
||||
target.conversion_factor = 1
|
||||
target.qty = flt(obj.qty) - flt(obj.ordered_qty)
|
||||
target.transfer_qty = flt(obj.qty) - flt(obj.ordered_qty)
|
||||
if source_parent.material_request_type == "Material Transfer":
|
||||
target.t_warehouse = obj.warehouse
|
||||
else:
|
||||
target.s_warehouse = obj.warehouse
|
||||
|
||||
def set_missing_values(source, target):
|
||||
target.purpose = source.material_request_type
|
||||
target.run_method("get_stock_and_rate")
|
||||
|
||||
if obj.material_request_type=="Material Issue":
|
||||
warehouse = "s_warehouse"
|
||||
else:
|
||||
warehouse = "t_warehouse"
|
||||
doclist = get_mapped_doc("Material Request", source_name, {
|
||||
"Material Request": {
|
||||
"doctype": "Stock Entry",
|
||||
@ -323,7 +320,6 @@ def make_stock_entry(source_name, target_doc=None):
|
||||
"name": "material_request_item",
|
||||
"parent": "material_request",
|
||||
"uom": "stock_uom",
|
||||
"warehouse": warehouse
|
||||
},
|
||||
"postprocess": update_item
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ class TestMaterialRequest(unittest.TestCase):
|
||||
mr.name)
|
||||
|
||||
mr = frappe.get_doc("Material Request", mr.name)
|
||||
mr.material_request_type = "Transfer"
|
||||
mr.material_request_type = "Material Transfer"
|
||||
mr.submit()
|
||||
se = make_stock_entry(mr.name)
|
||||
|
||||
@ -168,7 +168,7 @@ class TestMaterialRequest(unittest.TestCase):
|
||||
|
||||
# submit material request of type Purchase
|
||||
mr = frappe.copy_doc(test_records[0])
|
||||
mr.material_request_type = "Transfer"
|
||||
mr.material_request_type = "Material Transfer"
|
||||
mr.insert()
|
||||
mr.submit()
|
||||
|
||||
@ -257,7 +257,7 @@ class TestMaterialRequest(unittest.TestCase):
|
||||
|
||||
# submit material request of type Purchase
|
||||
mr = frappe.copy_doc(test_records[0])
|
||||
mr.material_request_type = "Transfer"
|
||||
mr.material_request_type = "Material Transfer"
|
||||
mr.insert()
|
||||
mr.submit()
|
||||
|
||||
@ -330,9 +330,9 @@ class TestMaterialRequest(unittest.TestCase):
|
||||
self.assertEquals(current_requested_qty_item2, existing_requested_qty_item2 + 3.0)
|
||||
|
||||
def test_incorrect_mapping_of_stock_entry(self):
|
||||
# submit material request of type Purchase
|
||||
# submit material request of type Transfer
|
||||
mr = frappe.copy_doc(test_records[0])
|
||||
mr.material_request_type = "Transfer"
|
||||
mr.material_request_type = "Material Transfer"
|
||||
mr.insert()
|
||||
mr.submit()
|
||||
|
||||
@ -363,6 +363,17 @@ class TestMaterialRequest(unittest.TestCase):
|
||||
se = frappe.copy_doc(se_doc)
|
||||
self.assertRaises(frappe.MappingMismatchError, se.insert)
|
||||
|
||||
# submit material request of type Transfer
|
||||
mr = frappe.copy_doc(test_records[0])
|
||||
mr.material_request_type = "Material Issue"
|
||||
mr.insert()
|
||||
mr.submit()
|
||||
|
||||
# map a stock entry
|
||||
from erpnext.stock.doctype.material_request.material_request import make_stock_entry
|
||||
se_doc = make_stock_entry(mr.name)
|
||||
self.assertEquals(se_doc.get("mtn_details")[0].s_warehouse, "_Test Warehouse - _TC")
|
||||
|
||||
def test_warehouse_company_validation(self):
|
||||
from erpnext.stock.utils import InvalidWarehouseCompany
|
||||
mr = frappe.copy_doc(test_records[0])
|
||||
|
@ -625,7 +625,8 @@ class StockEntry(StockController):
|
||||
mreq_item = frappe.db.get_value("Material Request Item",
|
||||
{"name": item.material_request_item, "parent": item.material_request},
|
||||
["item_code", "warehouse", "idx"], as_dict=True)
|
||||
if mreq_item.item_code != item.item_code or mreq_item.warehouse != item.t_warehouse:
|
||||
if mreq_item.item_code != item.item_code or \
|
||||
mreq_item.warehouse != (item.s_warehouse if self.purpose== "Material Issue" else item.t_warehouse):
|
||||
frappe.throw(_("Item or Warehouse for row {0} does not match Material Request").format(item.idx),
|
||||
frappe.MappingMismatchError)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user