Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: material request status (backport #44917) #44918

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion erpnext/controllers/status_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
38 changes: 38 additions & 0 deletions erpnext/stock/doctype/material_request/test_material_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
make_supplier_quotation,
raise_work_orders,
)
from erpnext.stock.doctype.warehouse.test_warehouse import create_warehouse


class TestMaterialRequest(FrappeTestCase):
Expand Down Expand Up @@ -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()

Expand Down
Loading