fix: non stock uom validation for serial and batch (#39018) * fix: non stock uom validation for serial and batch * test: delivery note for batch with non stock uom (cherry picked from commit 0c6de4ecb299daf5359fcd51041942a26f94693d) Co-authored-by: rohitwaghchaure <rohitw1991@gmail.com>
This commit is contained in:
parent
3a7506ecbc
commit
89d1069472
@ -586,6 +586,8 @@ class SalesInvoice(SellingController):
|
|||||||
"Serial and Batch Bundle",
|
"Serial and Batch Bundle",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self.delete_auto_created_batches()
|
||||||
|
|
||||||
def update_status_updater_args(self):
|
def update_status_updater_args(self):
|
||||||
if cint(self.update_stock):
|
if cint(self.update_stock):
|
||||||
self.status_updater.append(
|
self.status_updater.append(
|
||||||
|
@ -1414,10 +1414,11 @@ class TestSalesInvoice(FrappeTestCase):
|
|||||||
|
|
||||||
def test_serialized_cancel(self):
|
def test_serialized_cancel(self):
|
||||||
si = self.test_serialized()
|
si = self.test_serialized()
|
||||||
si.cancel()
|
si.reload()
|
||||||
|
|
||||||
serial_nos = get_serial_nos_from_bundle(si.get("items")[0].serial_and_batch_bundle)
|
serial_nos = get_serial_nos_from_bundle(si.get("items")[0].serial_and_batch_bundle)
|
||||||
|
|
||||||
|
si.cancel()
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
frappe.db.get_value("Serial No", serial_nos[0], "warehouse"), "_Test Warehouse - _TC"
|
frappe.db.get_value("Serial No", serial_nos[0], "warehouse"), "_Test Warehouse - _TC"
|
||||||
)
|
)
|
||||||
|
@ -81,6 +81,7 @@
|
|||||||
"warehouse",
|
"warehouse",
|
||||||
"target_warehouse",
|
"target_warehouse",
|
||||||
"quality_inspection",
|
"quality_inspection",
|
||||||
|
"pick_serial_and_batch",
|
||||||
"serial_and_batch_bundle",
|
"serial_and_batch_bundle",
|
||||||
"batch_no",
|
"batch_no",
|
||||||
"incoming_rate",
|
"incoming_rate",
|
||||||
@ -897,12 +898,18 @@
|
|||||||
"options": "Serial and Batch Bundle",
|
"options": "Serial and Batch Bundle",
|
||||||
"print_hide": 1,
|
"print_hide": 1,
|
||||||
"search_index": 1
|
"search_index": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"depends_on": "eval:parent.update_stock === 1",
|
||||||
|
"fieldname": "pick_serial_and_batch",
|
||||||
|
"fieldtype": "Button",
|
||||||
|
"label": "Pick Serial / Batch No"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2023-11-14 18:34:10.479329",
|
"modified": "2023-12-29 13:03:14.121298",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Sales Invoice Item",
|
"name": "Sales Invoice Item",
|
||||||
|
@ -431,6 +431,8 @@ class DeliveryNote(SellingController):
|
|||||||
"Serial and Batch Bundle",
|
"Serial and Batch Bundle",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self.delete_auto_created_batches()
|
||||||
|
|
||||||
def update_stock_reservation_entries(self) -> None:
|
def update_stock_reservation_entries(self) -> None:
|
||||||
"""Updates Delivered Qty in Stock Reservation Entries."""
|
"""Updates Delivered Qty in Stock Reservation Entries."""
|
||||||
|
|
||||||
|
@ -1478,6 +1478,46 @@ class TestDeliveryNote(FrappeTestCase):
|
|||||||
returned_dn.reload()
|
returned_dn.reload()
|
||||||
self.assertAlmostEqual(returned_dn.items[0].incoming_rate, 200.0)
|
self.assertAlmostEqual(returned_dn.items[0].incoming_rate, 200.0)
|
||||||
|
|
||||||
|
def test_batch_with_non_stock_uom(self):
|
||||||
|
frappe.db.set_single_value(
|
||||||
|
"Stock Settings", "auto_create_serial_and_batch_bundle_for_outward", 1
|
||||||
|
)
|
||||||
|
|
||||||
|
item = make_item(
|
||||||
|
properties={
|
||||||
|
"has_batch_no": 1,
|
||||||
|
"create_new_batch": 1,
|
||||||
|
"batch_number_series": "TESTBATCH.#####",
|
||||||
|
"stock_uom": "Nos",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
if not frappe.db.exists("UOM Conversion Detail", {"parent": item.name, "uom": "Kg"}):
|
||||||
|
item.append("uoms", {"uom": "Kg", "conversion_factor": 5.0})
|
||||||
|
item.save()
|
||||||
|
|
||||||
|
item_code = item.name
|
||||||
|
|
||||||
|
make_stock_entry(item_code=item_code, target="_Test Warehouse - _TC", qty=5, basic_rate=100.0)
|
||||||
|
dn = create_delivery_note(
|
||||||
|
item_code=item_code, qty=1, rate=500, warehouse="_Test Warehouse - _TC", do_not_save=True
|
||||||
|
)
|
||||||
|
dn.items[0].uom = "Kg"
|
||||||
|
dn.items[0].conversion_factor = 5.0
|
||||||
|
|
||||||
|
dn.save()
|
||||||
|
dn.submit()
|
||||||
|
|
||||||
|
self.assertEqual(dn.items[0].stock_qty, 5.0)
|
||||||
|
voucher_detail_no = dn.items[0].name
|
||||||
|
delivered_batch_qty = frappe.db.get_value(
|
||||||
|
"Serial and Batch Bundle", {"voucher_detail_no": voucher_detail_no}, "total_qty"
|
||||||
|
)
|
||||||
|
self.assertEqual(abs(delivered_batch_qty), 5.0)
|
||||||
|
|
||||||
|
frappe.db.set_single_value(
|
||||||
|
"Stock Settings", "auto_create_serial_and_batch_bundle_for_outward", 0
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def create_delivery_note(**args):
|
def create_delivery_note(**args):
|
||||||
dn = frappe.new_doc("Delivery Note")
|
dn = frappe.new_doc("Delivery Note")
|
||||||
|
@ -483,7 +483,11 @@ class SerialandBatchBundle(Document):
|
|||||||
if row.get("doctype") in ["Subcontracting Receipt Supplied Item"]:
|
if row.get("doctype") in ["Subcontracting Receipt Supplied Item"]:
|
||||||
qty_field = "consumed_qty"
|
qty_field = "consumed_qty"
|
||||||
|
|
||||||
if abs(abs(flt(self.total_qty, precision)) - abs(flt(row.get(qty_field), precision))) > 0.01:
|
qty = row.get(qty_field)
|
||||||
|
if qty_field == "qty" and row.get("stock_qty"):
|
||||||
|
qty = row.get("stock_qty")
|
||||||
|
|
||||||
|
if abs(abs(flt(self.total_qty, precision)) - abs(flt(qty, precision))) > 0.01:
|
||||||
self.throw_error_message(
|
self.throw_error_message(
|
||||||
f"Total quantity {abs(flt(self.total_qty))} in the Serial and Batch Bundle {bold(self.name)} does not match with the quantity {abs(flt(row.get(qty_field)))} for the Item {bold(self.item_code)} in the {self.voucher_type} # {self.voucher_no}"
|
f"Total quantity {abs(flt(self.total_qty))} in the Serial and Batch Bundle {bold(self.name)} does not match with the quantity {abs(flt(row.get(qty_field)))} for the Item {bold(self.item_code)} in the {self.voucher_type} # {self.voucher_no}"
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user