diff --git a/erpnext/patches.txt b/erpnext/patches.txt index ab96c014601..8080b3a7e9a 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -451,4 +451,5 @@ erpnext.patches.v15_0.migrate_old_item_wise_tax_detail_data_to_table erpnext.patches.v16_0.migrate_budget_records_to_new_structure erpnext.patches.v16_0.update_currency_exchange_settings_for_frankfurter #2025-12-11 erpnext.patches.v16_0.migrate_account_freezing_settings_to_company -erpnext.patches.v16_0.populate_budget_distribution_total \ No newline at end of file +erpnext.patches.v16_0.populate_budget_distribution_total +erpnext.patches.v16_0.set_mr_picked_qty \ No newline at end of file diff --git a/erpnext/patches/v16_0/set_mr_picked_qty.py b/erpnext/patches/v16_0/set_mr_picked_qty.py new file mode 100644 index 00000000000..3e4f19bee79 --- /dev/null +++ b/erpnext/patches/v16_0/set_mr_picked_qty.py @@ -0,0 +1,12 @@ +import frappe + + +def execute(): + if data := frappe.get_all( + "Pick List Item", + filters={"material_request_item": ["is", "set"], "docstatus": 1}, + fields=["material_request_item", {"SUM": "picked_qty", "as": "picked_qty"}], + group_by="material_request_item", + ): + data = {d.material_request_item: {"picked_qty": d.picked_qty} for d in data} + frappe.db.bulk_update("Material Request Item", data) diff --git a/erpnext/stock/doctype/material_request/test_material_request.py b/erpnext/stock/doctype/material_request/test_material_request.py index 578e1622cfb..34ff6c46208 100644 --- a/erpnext/stock/doctype/material_request/test_material_request.py +++ b/erpnext/stock/doctype/material_request/test_material_request.py @@ -6,7 +6,6 @@ import frappe -import frappe.model from frappe.tests import IntegrationTestCase from frappe.utils import flt, today @@ -1004,6 +1003,25 @@ class TestMaterialRequest(IntegrationTestCase): pl_for_pending = create_pick_list(mr.name) self.assertEqual(pl_for_pending.locations[0].qty, 5) + def test_mr_pick_list_qty_validation(self): + """Test for checking pick list qty validation from Material Request""" + + mr = make_material_request(material_request_type="Material Transfer") + pl = create_pick_list(mr.name) + pl.locations[0].qty = 9 + pl.locations[0].stock_qty = 9 + pl.submit() + + mr.reload() + self.assertEqual(mr.items[0].picked_qty, 9) + + pl = create_pick_list(mr.name) + self.assertEqual(pl.locations[0].qty, 1) + + pl.locations[0].qty = 2 + pl.locations[0].stock_qty = 2 + self.assertRaises(frappe.ValidationError, pl.submit) + def test_mr_status_with_partial_and_excess_end_transit(self): material_request = make_material_request( material_request_type="Material Transfer",