update test

don't use half the quantity so that the reserved qty is different from
available qty
This commit is contained in:
Alexandre Fayolle
2014-09-08 15:29:03 +02:00
committed by aliciagarzo
parent 3a212bc454
commit 032a5af5b3
2 changed files with 64 additions and 8 deletions

View File

@@ -131,7 +131,7 @@ class StockReservation(models.Model):
@api.multi
def release(self):
"""
Releas moves from reservation
Release moves from reservation
"""
move_recs = self.move_id
move_recs.action_cancel()
@@ -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

View File

@@ -1,7 +1,7 @@
-
I create a product to test the stock reservation
-
!record {model: product.product, id: product_sorbet}:
!record {model: product.product, id: product_sorbet}:
default_code: 001SORBET
name: Sorbet
type: product
@@ -10,6 +10,16 @@
standard_price: 70.0
uom_id: product.product_uom_kgm
uom_po_id: product.product_uom_kgm
-
I create a stock orderpoint for the product
-
!record {model: stock.warehouse.orderpoint, id: sorbet_orderpoint}:
warehouse_id: stock.warehouse0
location_id: stock.stock_location_stock
product_id: product_sorbet
product_uom: product.product_uom_kgm
product_min_qty: 4.0
product_max_qty: 15.0
-
I update the current stock of the Sorbet with 10 kgm
-
@@ -27,24 +37,50 @@
product = self.browse(cr, uid, ref('stock_reserve.product_sorbet'), context=context)
assert product.virtual_available == 10, "Stock is not updated."
-
I create a stock reservation for 5 kgm
I create a stock reservation for 6 kgm
-
!record {model: stock.reservation, id: reserv_sorbet1}:
product_id: product_sorbet
product_uom_qty: 5.0
product_uom_qty: 6.0
product_uom: product.product_uom_kgm
name: reserve 5 kgm of sorbet for test
name: reserve 6 kg of sorbet for test
-
I confirm the reservation
-
!python {model: stock.reservation}: |
self.reserve(cr, uid, [ref('reserv_sorbet1')], context=context)
-
I create a stock reservation for 500g
-
!record {model: stock.reservation, id: reserv_sorbet2}:
product_id: product_sorbet
product_uom_qty: 500
product_uom: product.product_uom_gram
name: reserve 500g of sorbet for test
-
I confirm the reservation
-
!python {model: stock.reservation}: |
self.reserve(cr, uid, [ref('reserv_sorbet2')], context=context)
-
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 == 5, "Stock is not updated."
assert product.virtual_available == 3.5, "Stock is not updated."
-
I run the scheduler
-
!python {model: procurement.order}: |
self.run_scheduler(cr, uid)
-
The procurement linked to the orderpoint must be in exception (no routes configured)
-
!python {model: stock.warehouse.orderpoint}: |
orderpoint = self.browse(cr, uid, ref('sorbet_orderpoint'))
assert orderpoint.procurement_ids[0].state == 'exception', 'procurement must be in exception as there is no rule for procurement'
import math
assert orderpoint.procurement_ids[0].product_qty == math.ceil(15 - 3.5), 'wrong product qty ordered'
-
I release the reservation
-
@@ -55,4 +91,24 @@
-
!python {model: product.product}: |
product = self.browse(cr, uid, ref('stock_reserve.product_sorbet'), context=context)
assert product.virtual_available == 10, "Stock is not updated."
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."