@@ -288,3 +288,57 @@ def test_avco_product_receipt(self):
288288 move_in .stock_valuation_layer_ids .lot_ids ,
289289 "Lot IDs should be empty for AVCO product." ,
290290 )
291+
292+ def test_fifo_revaluation_lot (self ):
293+ receipt_picking , move_in = self .create_picking (
294+ self .supplier_location ,
295+ self .stock_location ,
296+ self .picking_type_in ,
297+ ["001" , "002" , "003" ],
298+ 100.0 ,
299+ )
300+ self .assertEqual (len (receipt_picking .move_line_ids ), 3 )
301+ svls = move_in .stock_valuation_layer_ids
302+ self .assertEqual (svls .remaining_value , 1500.0 )
303+ self .assertEqual (svls .remaining_qty , 15.0 )
304+ lot_001 = self .env ["stock.lot" ].search (
305+ [("product_id" , "=" , self .product .id ), ("name" , "=" , "001" )], limit = 1
306+ )
307+ self .assertTrue (lot_001 , "Lot 001 should exist" )
308+ stock_valuation_account = self .env ["account.account" ].create (
309+ {
310+ "name" : "Stock Valuation" ,
311+ "code" : "StockValuation" ,
312+ "account_type" : "asset_current" ,
313+ "reconcile" : True ,
314+ }
315+ )
316+ revaluation = self .env ["stock.valuation.layer.revaluation" ].create (
317+ {
318+ "product_id" : self .product .id ,
319+ "company_id" : self .env .company .id ,
320+ "added_value" : 10.0 ,
321+ "lot_id" : lot_001 .id ,
322+ "reason" : "Test Revaluation Lot 001" ,
323+ "account_id" : stock_valuation_account .id ,
324+ }
325+ )
326+ revaluation .action_validate_revaluation ()
327+ svl_revaluation = self .env ["stock.valuation.layer" ].search (
328+ [
329+ ("product_id" , "=" , self .product .id ),
330+ ("lot_ids" , "in" , lot_001 .ids ),
331+ ],
332+ limit = 1 ,
333+ order = "id desc" ,
334+ )
335+ self .assertTrue (svl_revaluation , "Revaluation SVL should be created" )
336+ self .assertIn (
337+ lot_001 , svl_revaluation .lot_ids , "Revaluation SVL should have correct lot"
338+ )
339+ self .assertEqual (svl_revaluation .value , 10.0 )
340+ self .assertEqual (
341+ svl_revaluation .remaining_value ,
342+ 10.0 ,
343+ "Remaining value should be added in revaluation SVL" ,
344+ )
0 commit comments