mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-25 14:11:45 +01:00
* fix: validation for serial no (#44133)
(cherry picked from commit 93c8b4c39a)
# Conflicts:
# erpnext/stock/doctype/stock_entry/test_stock_entry.py
* chore: fix conflicts
---------
Co-authored-by: rohitwaghchaure <rohitw1991@gmail.com>
This commit is contained in:
@@ -749,10 +749,6 @@ class SerialandBatchBundle(Document):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def validate_incorrect_serial_nos(self, serial_nos):
|
def validate_incorrect_serial_nos(self, serial_nos):
|
||||||
if self.voucher_type == "Stock Entry" and self.voucher_no:
|
|
||||||
if frappe.get_cached_value("Stock Entry", self.voucher_no, "purpose") == "Repack":
|
|
||||||
return
|
|
||||||
|
|
||||||
incorrect_serial_nos = frappe.get_all(
|
incorrect_serial_nos = frappe.get_all(
|
||||||
"Serial No",
|
"Serial No",
|
||||||
filters={"name": ("in", serial_nos), "item_code": ("!=", self.item_code)},
|
filters={"name": ("in", serial_nos), "item_code": ("!=", self.item_code)},
|
||||||
|
|||||||
@@ -970,61 +970,6 @@ class TestStockEntry(FrappeTestCase):
|
|||||||
|
|
||||||
self.assertRaises(frappe.ValidationError, ste.submit)
|
self.assertRaises(frappe.ValidationError, ste.submit)
|
||||||
|
|
||||||
def test_same_serial_nos_in_repack_or_manufacture_entries(self):
|
|
||||||
s1 = make_serialized_item(target_warehouse="_Test Warehouse - _TC")
|
|
||||||
serial_nos = get_serial_nos_from_bundle(s1.get("items")[0].serial_and_batch_bundle)
|
|
||||||
|
|
||||||
s2 = make_stock_entry(
|
|
||||||
item_code="_Test Serialized Item With Series",
|
|
||||||
source="_Test Warehouse - _TC",
|
|
||||||
qty=2,
|
|
||||||
basic_rate=100,
|
|
||||||
purpose="Repack",
|
|
||||||
serial_no=serial_nos,
|
|
||||||
do_not_save=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
frappe.flags.use_serial_and_batch_fields = True
|
|
||||||
|
|
||||||
cls_obj = SerialBatchCreation(
|
|
||||||
{
|
|
||||||
"type_of_transaction": "Inward",
|
|
||||||
"serial_and_batch_bundle": s2.items[0].serial_and_batch_bundle,
|
|
||||||
"item_code": "_Test Serialized Item",
|
|
||||||
"warehouse": "_Test Warehouse - _TC",
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
cls_obj.duplicate_package()
|
|
||||||
bundle_id = cls_obj.serial_and_batch_bundle
|
|
||||||
doc = frappe.get_doc("Serial and Batch Bundle", bundle_id)
|
|
||||||
doc.db_set(
|
|
||||||
{
|
|
||||||
"item_code": "_Test Serialized Item",
|
|
||||||
"warehouse": "_Test Warehouse - _TC",
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
doc.load_from_db()
|
|
||||||
|
|
||||||
s2.append(
|
|
||||||
"items",
|
|
||||||
{
|
|
||||||
"item_code": "_Test Serialized Item",
|
|
||||||
"t_warehouse": "_Test Warehouse - _TC",
|
|
||||||
"qty": 2,
|
|
||||||
"basic_rate": 120,
|
|
||||||
"expense_account": "Stock Adjustment - _TC",
|
|
||||||
"conversion_factor": 1.0,
|
|
||||||
"cost_center": "_Test Cost Center - _TC",
|
|
||||||
"serial_and_batch_bundle": bundle_id,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
s2.submit()
|
|
||||||
s2.cancel()
|
|
||||||
frappe.flags.use_serial_and_batch_fields = False
|
|
||||||
|
|
||||||
def test_quality_check(self):
|
def test_quality_check(self):
|
||||||
item_code = "_Test Item For QC"
|
item_code = "_Test Item For QC"
|
||||||
if not frappe.db.exists("Item", item_code):
|
if not frappe.db.exists("Item", item_code):
|
||||||
|
|||||||
Reference in New Issue
Block a user