@@ -1793,6 +1793,47 @@ def test_stock_reco_with_opening_stock_with_diff_inventory(self):
17931793 elif s .id_plant == plant_b .name :
17941794 self .assertEqual (s .actual_qty , 3 )
17951795
1796+ def test_serial_no_status_with_backdated_stock_reco (self ):
1797+ from erpnext .stock .doctype .delivery_note .test_delivery_note import create_delivery_note
1798+
1799+ item_code = self .make_item (
1800+ "Test Item" ,
1801+ {
1802+ "is_stock_item" : 1 ,
1803+ "has_serial_no" : 1 ,
1804+ "serial_no_series" : "SERIAL.###" ,
1805+ },
1806+ ).name
1807+
1808+ warehouse = "_Test Warehouse - _TC"
1809+
1810+ reco = create_stock_reconciliation (
1811+ item_code = item_code ,
1812+ posting_date = add_days (nowdate (), - 2 ),
1813+ warehouse = warehouse ,
1814+ qty = 1 ,
1815+ rate = 80 ,
1816+ purpose = "Opening Stock" ,
1817+ )
1818+
1819+ serial_no = get_serial_nos_from_bundle (reco .items [0 ].serial_and_batch_bundle )[0 ]
1820+
1821+ create_delivery_note (
1822+ item_code = item_code , warehouse = warehouse , qty = 1 , rate = 100 , posting_date = nowdate ()
1823+ )
1824+
1825+ self .assertEqual (frappe .get_value ("Serial No" , serial_no , "status" ), "Delivered" )
1826+
1827+ reco = create_stock_reconciliation (
1828+ item_code = item_code ,
1829+ posting_date = add_days (nowdate (), - 1 ),
1830+ warehouse = warehouse ,
1831+ qty = 1 ,
1832+ rate = 90 ,
1833+ )
1834+
1835+ self .assertEqual (frappe .get_value ("Serial No" , serial_no , "status" ), "Delivered" )
1836+
17961837
17971838def create_batch_item_with_batch (item_name , batch_id ):
17981839 batch_item_doc = create_item (item_name , is_stock_item = 1 )
0 commit comments