test: patch: add test case and patch

This commit is contained in:
Mihir Kandoi
2025-12-17 20:16:13 +05:30
committed by mihir-kandoi
parent 17320d1062
commit 333169e52b
3 changed files with 33 additions and 2 deletions

View File

@@ -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
erpnext.patches.v16_0.populate_budget_distribution_total
erpnext.patches.v16_0.set_mr_picked_qty

View File

@@ -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)

View File

@@ -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",