-
- I create an inventory of 10 products
- I create an inventory
++ In order to test the inventory, I create a new product
++-
++ !record {model: product.product, id: inventory_product}:
++ name: inventory prod
++ type: product
++-
++ I create an inventory for this product only
-
!record {model: stock.inventory, id: inventory_test0}:
name: Test
- inventory_line_id:
- - product_id: product.product_product_3
- product_qty: 10
- location_id: stock.stock_location_14
++ product_id: inventory_product
++
+ -
+ I create the wizard to confirm the inventory
+ -
+ !record {model: stock.fill.inventory, id: inventory_test0_wizard}:
+ set_stock_zero: False
+ -
+ I fill this inventory
+ -
+ !python {model: stock.inventory.line}: |
+ context = {'active_ids': [ref('inventory_test0')]}
+ self.pool.get('stock.fill.inventory').fill_inventory(cr, uid, [ref('inventory_test0_wizard')], context=context)
+ -
- I create an inventory line with 10 product
++ I check that my inventory has no line, as the product is a new one.
++-
++ !python {model: stock.inventory}: |
++ inv = self.browse(cr, uid, ref('inventory_test0'), context=context)
++ assert len(inv.line_ids) == 0, "Wrong number of inventory lines."
++-
++ I add an inventory line and say i have 10 products in stock
+ -
+ !record {model: stock.inventory.line, id: inventory_testline0}:
+ inventory_id: stock.inventory_test0
- product_id: product.product_product_3
++ product_id: inventory_product
+ product_qty: 10
+ location_id: stock.stock_location_14
-
- I post this inventory
+ I confirm this inventory
-
!python {model: stock.inventory}: |
- self.action_confirm(cr, uid, [ref('inventory_test0')], context=context)
self.action_done(cr, uid, [ref('inventory_test0')], context=context)
-
I check that this inventory has a stock.move and a quant
-
!python {model: stock.inventory}: |
inv = self.browse(cr, uid, ref('inventory_test0'), context=context)
- assert len(inv.move_ids) == 1, "No move created for the inventory."
+ assert len(inv.move_ids) >= 1, "No move created for the inventory."
assert len(inv.move_ids[0].quant_ids) >= 1, "No quant created for this inventory"
-
-- I check that the quantity on hand is 10 on the location and it's parent.
++ I check that the quantity on hand is 10 on the location and its parent.
-
!python {model: product.product}: |
context['location'] = ref('stock.stock_location_14')
product = self.browse(cr, uid, ref('product.product_product_3'), context=context)
-- assert product.qty_available==10, 'Expecting 10 products, got %.2f on location stock_location_14!' % (product.qty_available,)
++ assert product.qty_available == 10, 'Expecting 10 products, got %.2f on location stock_location_14!' % (product.qty_available,)
context['location'] = ref('stock.stock_location_stock')
product = self.browse(cr, uid, ref('product.product_product_3'), context=context)
-- assert product.qty_available==10, 'Expecting 10 products, got %.2f on location stock_location_stock!' % (product.qty_available,)
++ assert product.qty_available == 10, 'Expecting 10 products, got %.2f on location stock_location_stock!' % (product.qty_available,)
-
I check that the quantity on hand is 0 on a brother location
-
!python {model: product.product}: |
context['location'] = ref('stock.stock_location_components')
product = self.browse(cr, uid, ref('product.product_product_3'), context=context)
-- assert product.qty_available==0, 'Expecting 0 products, got %.2f on location stock_location_components!' % (product.qty_available,)
++ assert product.qty_available == 0, 'Expecting 0 products, got %.2f on location stock_location_components!' % (product.qty_available,)
-
- I create an inventory of 20 products
+ I create another inventory
-
!record {model: stock.inventory, id: inventory_test1}:
-- name: Test
- inventory_line_id:
- - product_id: product.product_product_3
- product_qty: 20
- location_id: stock.stock_location_14
++ name: second test inventory
++ product_id: inventory_product
-
- I post this new inventory
+ I fill this new inventory
-
!python {model: stock.inventory}: |
- self.action_confirm(cr, uid, [ref('inventory_test1')], context=context)
- self.action_done(cr, uid, [ref('inventory_test1')], context=context)
-
+ context = {'active_ids': [ref('inventory_test1')]}
+ self.pool.get('stock.fill.inventory').fill_inventory(cr, uid, [ref('inventory_test0_wizard')], context=context)
-
- I check that the quantity on hand is 20 on the location and it's parent.
- I create an inventory line with 20 product on this new inventory
++ I check that my inventory has one line, with a quantity of 10.
-
- !python {model: product.product}: |
- context['location'] = ref('stock.stock_location_14')
- product = self.browse(cr, uid, ref('product.product_product_3'), context=context)
- assert product.qty_available==20, 'Expecting 20 products, got %.2f on location stock_location_14!' % (product.qty_available,)
- !record {model: stock.inventory.line, id: inventory_testline0}:
- inventory_id: stock.inventory_test1
- product_id: product.product_product_3
- product_qty: 20
- location_id: stock.stock_location_14
++ !python {model: stock.inventory}: |
++ inv = self.browse(cr, uid, ref('inventory_test1'), context=context)
++ assert len(inv.line_ids) == 1, "Wrong number of inventory lines."
++ assert len(inv.line_ids[0].product_qty) == 10, "Wrong quantity in inventory line."
++ assert len(inv.line_ids[0].product_id.id) == ref('inventory_product'), "Wrong product in inventory line."
+-
- !record {model: stock.inventory, id: inventory_test2}:
- name: Test
- inventory_line_id:
- - product_id: product.product_product_3
- product_qty: 18
- location_id: stock.stock_location_14
++ I modify the inventory line and set the quantity to 20 product on this new inventory
++-
++ !python {model: stock.inventory}: |
++ inv = self.browse(cr, uid, ref('inventory_test1'), context=context)
++ self.pool.get('stock.inventory.line').write(cr, uid, inv.line_ids[0].id, {'product_qty': 20})
-
- I post this new inventory
+ I confirm this inventory
-
!python {model: stock.inventory}: |
- self.action_confirm(cr, uid, [ref('inventory_test2')], context=context)
- self.action_done(cr, uid, [ref('inventory_test2')], context=context)
+ self.action_done(cr, uid, [ref('inventory_test1')], context=context)
-
- I check that the quantity on hand is 18 on the location and it's parent.
- I check that the quantity on hand is 20 on the location and it's parent.
++ I check that the quantity on hand is 20 on the location and its parent.
-
!python {model: product.product}: |
context['location'] = ref('stock.stock_location_14')
-- product = self.browse(cr, uid, ref('product.product_product_3'), context=context)
- assert product.qty_available==18, 'Expecting 18 products, got %.2f on location stock_location_14!' % (product.qty_available,)
- assert product.qty_available==20, 'Expecting 20 products, got %.2f on location stock_location_14!' % (product.qty_available,)
++ product = self.browse(cr, uid, ref('inventory_product'), context=context)
++ assert product.qty_available == 20, 'Expecting 20 products, got %.2f on location stock_location_14!' % (product.qty_available,)