mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-21 07:38:29 +00:00
Co-authored-by: Mihir Kandoi <kandoimihir@gmail.com> fix: remove unneccessary function for serial no status updation (#54191)
This commit is contained in:
@@ -1793,6 +1793,47 @@ class TestStockReconciliation(FrappeTestCase, StockTestMixin):
|
|||||||
elif s.id_plant == plant_b.name:
|
elif s.id_plant == plant_b.name:
|
||||||
self.assertEqual(s.actual_qty, 3)
|
self.assertEqual(s.actual_qty, 3)
|
||||||
|
|
||||||
|
def test_serial_no_status_with_backdated_stock_reco(self):
|
||||||
|
from erpnext.stock.doctype.delivery_note.test_delivery_note import create_delivery_note
|
||||||
|
|
||||||
|
item_code = self.make_item(
|
||||||
|
"Test Item",
|
||||||
|
{
|
||||||
|
"is_stock_item": 1,
|
||||||
|
"has_serial_no": 1,
|
||||||
|
"serial_no_series": "SERIAL.###",
|
||||||
|
},
|
||||||
|
).name
|
||||||
|
|
||||||
|
warehouse = "_Test Warehouse - _TC"
|
||||||
|
|
||||||
|
reco = create_stock_reconciliation(
|
||||||
|
item_code=item_code,
|
||||||
|
posting_date=add_days(nowdate(), -2),
|
||||||
|
warehouse=warehouse,
|
||||||
|
qty=1,
|
||||||
|
rate=80,
|
||||||
|
purpose="Opening Stock",
|
||||||
|
)
|
||||||
|
|
||||||
|
serial_no = get_serial_nos_from_bundle(reco.items[0].serial_and_batch_bundle)[0]
|
||||||
|
|
||||||
|
create_delivery_note(
|
||||||
|
item_code=item_code, warehouse=warehouse, qty=1, rate=100, posting_date=nowdate()
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertEqual(frappe.get_value("Serial No", serial_no, "status"), "Delivered")
|
||||||
|
|
||||||
|
reco = create_stock_reconciliation(
|
||||||
|
item_code=item_code,
|
||||||
|
posting_date=add_days(nowdate(), -1),
|
||||||
|
warehouse=warehouse,
|
||||||
|
qty=1,
|
||||||
|
rate=90,
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertEqual(frappe.get_value("Serial No", serial_no, "status"), "Delivered")
|
||||||
|
|
||||||
|
|
||||||
def create_batch_item_with_batch(item_name, batch_id):
|
def create_batch_item_with_batch(item_name, batch_id):
|
||||||
batch_item_doc = create_item(item_name, is_stock_item=1)
|
batch_item_doc = create_item(item_name, is_stock_item=1)
|
||||||
|
|||||||
@@ -1063,34 +1063,6 @@ class update_entries_after:
|
|||||||
sabb_doc.voucher_no = None
|
sabb_doc.voucher_no = None
|
||||||
sabb_doc.cancel()
|
sabb_doc.cancel()
|
||||||
|
|
||||||
if sle.serial_and_batch_bundle and frappe.get_cached_value("Item", sle.item_code, "has_serial_no"):
|
|
||||||
self.update_serial_no_status(sle)
|
|
||||||
|
|
||||||
def update_serial_no_status(self, sle):
|
|
||||||
from erpnext.stock.serial_batch_bundle import get_serial_nos
|
|
||||||
|
|
||||||
serial_nos = get_serial_nos(sle.serial_and_batch_bundle)
|
|
||||||
if not serial_nos:
|
|
||||||
return
|
|
||||||
|
|
||||||
warehouse = None
|
|
||||||
status = "Inactive"
|
|
||||||
|
|
||||||
if sle.actual_qty > 0:
|
|
||||||
warehouse = sle.warehouse
|
|
||||||
status = "Active"
|
|
||||||
|
|
||||||
sn_table = frappe.qb.DocType("Serial No")
|
|
||||||
|
|
||||||
query = (
|
|
||||||
frappe.qb.update(sn_table)
|
|
||||||
.set(sn_table.warehouse, warehouse)
|
|
||||||
.set(sn_table.status, status)
|
|
||||||
.where(sn_table.name.isin(serial_nos))
|
|
||||||
)
|
|
||||||
|
|
||||||
query.run()
|
|
||||||
|
|
||||||
def calculate_valuation_for_serial_batch_bundle(self, sle):
|
def calculate_valuation_for_serial_batch_bundle(self, sle):
|
||||||
if not frappe.db.exists("Serial and Batch Bundle", sle.serial_and_batch_bundle):
|
if not frappe.db.exists("Serial and Batch Bundle", sle.serial_and_batch_bundle):
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user