From d342adbee8c533a53b32ad16bf207fb509321f8b Mon Sep 17 00:00:00 2001 From: Cedric Snauwaert Date: Wed, 7 Aug 2013 11:58:11 +0200 Subject: [PATCH 1/2] [FIX]stock_inventory_test: fix stock inventory test bzr revid: csn@openerp.com-20130807095811-jz95nfuguigwv90j --- addons/stock/stock.py | 1 + addons/stock/test/inventory.yml | 75 +++++++++++++++++---------------- 2 files changed, 40 insertions(+), 36 deletions(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 5bd89fdd44c..eb4cb46b0d5 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -1566,6 +1566,7 @@ class stock_inventory(osv.osv): for inv in self.browse(cr, uid, ids, context=context): if not inv.move_ids: self.action_check(cr, uid, [inv.id], context=context) + inv.refresh() move_obj.action_done(cr, uid, [x.id for x in inv.move_ids], context=context) self.write(cr, uid, [inv.id], {'state': 'done', 'date_done': time.strftime('%Y-%m-%d %H:%M:%S')}, context=context) return True diff --git a/addons/stock/test/inventory.yml b/addons/stock/test/inventory.yml index 3a9d4a4c5db..d5376e82348 100644 --- a/addons/stock/test/inventory.yml +++ b/addons/stock/test/inventory.yml @@ -1,24 +1,38 @@ - - I create an inventory of 10 products + I create an inventory - !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 - - I post this inventory + 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 +- + !record {model: stock.inventory.line, id: inventory_testline0}: + inventory_id: stock.inventory_test0 + product_id: product.product_product_3 + product_qty: 10 + location_id: stock.stock_location_14 +- + 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. @@ -38,21 +52,30 @@ 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,) - - 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 - - I post this new inventory + I fill this new inventory +- + !python {model: stock.inventory}: | + context = {'active_ids': [ref('inventory_test1')]} + self.pool.get('stock.fill.inventory').fill_inventory(cr, uid, [ref('inventory_test0_wizard')], context=context) + self.action_done(cr, uid, [ref('inventory_test1')], context=context) +- + I create an inventory line with 20 product on this new inventory +- + !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 +- + I confirm this 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) - - I check that the quantity on hand is 20 on the location and it's parent. - @@ -60,24 +83,4 @@ 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, id: inventory_test2}: - name: Test - inventory_line_id: - - product_id: product.product_product_3 - product_qty: 18 - location_id: stock.stock_location_14 -- - I post this new 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) -- - I check that the quantity on hand is 18 on the location and it's 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,) From 5a4f0fec0c1613fc438e3464bc2c4fdbff3358ec Mon Sep 17 00:00:00 2001 From: Cedric Snauwaert Date: Wed, 7 Aug 2013 12:08:49 +0200 Subject: [PATCH 2/2] [FIX]remove extra line bzr revid: csn@openerp.com-20130807100849-bnkyo20suoky18gc --- addons/stock/test/inventory.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/addons/stock/test/inventory.yml b/addons/stock/test/inventory.yml index d5376e82348..9fc2fc32b10 100644 --- a/addons/stock/test/inventory.yml +++ b/addons/stock/test/inventory.yml @@ -62,7 +62,6 @@ !python {model: stock.inventory}: | context = {'active_ids': [ref('inventory_test1')]} self.pool.get('stock.fill.inventory').fill_inventory(cr, uid, [ref('inventory_test0_wizard')], context=context) - self.action_done(cr, uid, [ref('inventory_test1')], context=context) - I create an inventory line with 20 product on this new inventory -