diff --git a/erpnext/controllers/status_updater.py b/erpnext/controllers/status_updater.py index e8aa6254d34d..e1cd0a1c3407 100644 --- a/erpnext/controllers/status_updater.py +++ b/erpnext/controllers/status_updater.py @@ -126,9 +126,13 @@ def validate_status(status, options): "Partially Received", "eval:self.status != 'Stopped' and self.per_received > 0 and self.per_received < 100 and self.docstatus == 1 and self.material_request_type == 'Purchase'", ], + [ + "Partially Received", + "eval:self.status != 'Stopped' and self.per_ordered < 100 and self.per_ordered > 0 and self.docstatus == 1 and self.material_request_type == 'Material Transfer'", + ], [ "Partially Ordered", - "eval:self.status != 'Stopped' and self.per_ordered < 100 and self.per_ordered > 0 and self.docstatus == 1", + "eval:self.status != 'Stopped' and self.per_ordered < 100 and self.per_ordered > 0 and self.docstatus == 1 and self.material_request_type != 'Material Transfer'", ], [ "Manufactured", diff --git a/erpnext/stock/doctype/material_request/material_request_list.js b/erpnext/stock/doctype/material_request/material_request_list.js index ee5c9e7b86c6..57332aa7730a 100644 --- a/erpnext/stock/doctype/material_request/material_request_list.js +++ b/erpnext/stock/doctype/material_request/material_request_list.js @@ -14,6 +14,12 @@ frappe.listview_settings["Material Request"] = { } } else if (doc.docstatus == 1 && flt(doc.per_ordered, precision) == 0) { return [__("Pending"), "orange", "per_ordered,=,0"]; + } else if ( + doc.docstatus == 1 && + flt(doc.per_ordered, precision) < 100 && + doc.material_request_type == "Material Transfer" + ) { + return [__("Partially Received"), "yellow", "per_ordered,<,100"]; } else if (doc.docstatus == 1 && flt(doc.per_ordered, precision) < 100) { return [__("Partially ordered"), "yellow", "per_ordered,<,100"]; } else if (doc.docstatus == 1 && flt(doc.per_ordered, precision) == 100) { diff --git a/erpnext/stock/doctype/material_request/test_material_request.py b/erpnext/stock/doctype/material_request/test_material_request.py index 4d48d50c9f0b..b0ea79641173 100644 --- a/erpnext/stock/doctype/material_request/test_material_request.py +++ b/erpnext/stock/doctype/material_request/test_material_request.py @@ -17,6 +17,7 @@ make_supplier_quotation, raise_work_orders, ) +from erpnext.stock.doctype.warehouse.test_warehouse import create_warehouse class TestMaterialRequest(FrappeTestCase): @@ -59,6 +60,43 @@ def test_make_stock_entry(self): self.assertEqual(se.doctype, "Stock Entry") self.assertEqual(len(se.get("items")), len(mr.get("items"))) + def test_partial_make_stock_entry(self): + from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry as _make_stock_entry + + mr = frappe.copy_doc(test_records[0]).insert() + + source_wh = create_warehouse( + warehouse_name="_Test Source Warehouse", + properties={"parent_warehouse": "All Warehouses - _TC"}, + company="_Test Company", + ) + + mr = frappe.get_doc("Material Request", mr.name) + mr.material_request_type = "Material Transfer" + + for row in mr.items: + _make_stock_entry( + item_code=row.item_code, + qty=10, + to_warehouse=source_wh, + company="_Test Company", + rate=100, + ) + + row.from_warehouse = source_wh + row.qty = 10 + + mr.save() + mr.submit() + + se = make_stock_entry(mr.name) + se.get("items")[0].qty = 5 + se.insert() + se.submit() + + mr.reload() + self.assertEqual(mr.status, "Partially Received") + def test_in_transit_make_stock_entry(self): mr = frappe.copy_doc(test_records[0]).insert()