mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
add test for expiration of reservations
fix a bug in the code to make the tests green
This commit is contained in:
@@ -145,7 +145,7 @@ class StockReservation(models.Model):
|
||||
if ids:
|
||||
domain.append(('id', 'in', ids))
|
||||
reserv_ids = self.search(domain)
|
||||
self.release(reserv_ids)
|
||||
reserv_ids.release()
|
||||
return True
|
||||
|
||||
@api.multi
|
||||
|
||||
@@ -92,3 +92,23 @@
|
||||
!python {model: product.product}: |
|
||||
product = self.browse(cr, uid, ref('stock_reserve.product_sorbet'), context=context)
|
||||
assert product.virtual_available == 9.5, "Stock is not updated."
|
||||
-
|
||||
I set the validity of the second reservation to yesterday
|
||||
-
|
||||
!python {model: stock.reservation}: |
|
||||
import datetime
|
||||
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT
|
||||
yesterday = datetime.date.today() - datetime.timedelta(days=1)
|
||||
yesterday = yesterday.strftime(DEFAULT_SERVER_DATE_FORMAT)
|
||||
self.write(cr, uid, [ref('reserv_sorbet2')], {'date_validity': yesterday})
|
||||
-
|
||||
I call the function releasing expired reservations
|
||||
-
|
||||
!python {model: stock.reservation}: |
|
||||
self.release_validity_exceeded(cr, uid, [])
|
||||
-
|
||||
I check Virtual stock of Sorbet after update reservation
|
||||
-
|
||||
!python {model: product.product}: |
|
||||
product = self.browse(cr, uid, ref('stock_reserve.product_sorbet'), context=context)
|
||||
assert product.virtual_available == 10.0, "Stock is not updated."
|
||||
|
||||
Reference in New Issue
Block a user