From e835bc1125df6ba2c9fe132defe9f9ef13d00efd Mon Sep 17 00:00:00 2001 From: "DBR (OpenERP)" Date: Thu, 8 Dec 2011 11:28:41 +0530 Subject: [PATCH] [IMP]stock: Improve the code for stock_physical_inventory.yml bzr revid: dbr@tinyerp.com-20111208055841-d2igdvi02wf8y1kn --- .../stock/test/stock_physical_inventory.yml | 34 +++++++------------ addons/stock/wizard/stock_fill_inventory.py | 2 +- 2 files changed, 13 insertions(+), 23 deletions(-) diff --git a/addons/stock/test/stock_physical_inventory.yml b/addons/stock/test/stock_physical_inventory.yml index 369a8200804..de44f989f31 100644 --- a/addons/stock/test/stock_physical_inventory.yml +++ b/addons/stock/test/stock_physical_inventory.yml @@ -4,43 +4,33 @@ I create a physical inventory and change the product quantity zero by making a physical inventory. - !record {model: stock.inventory, id: stock_physical_inventory0}: - company_id: base.main_company - date: !eval time.strftime('%Y-%m-%d %H:%M:%S') name: Physical inventory - state: draft - - I define and fill the inventory. Create record using create method. + I create record using create method. - !python {model: stock.fill.inventory}: | - vals = { - 'location_id': ref('stock_location_components'), - 'recursive': False, - 'set_stock_zero': True - } - ids = self.create(cr, uid, vals, context) - context.update({"full": "1", "active_model": "stock.inventory","active_ids": [ids]}) - self.view_init(cr, uid, ["set_stock_zero", "location_id", "recursive"], context) - inventory_id = context.get('ids') - self.fill_inventory(cr, uid, inventory_id, context) + ids = self.create(cr, uid, {'location_id': ref('stock_location_components'),'set_stock_zero': True}) + self.view_init(cr, uid, ["set_stock_zero", "location_id", "recursive"]) + self.fill_inventory(cr, uid, [ids],{"full": "1", "active_model": "stock.inventory","active_id": ids,"active_ids":[ref('stock_physical_inventory0')]}) - I confirm the inventory. - !python {model: stock.inventory}: | inventory = self.browse(cr, uid, [ref('stock_physical_inventory0')])[0] - self.action_confirm(cr,uid,[ref('stock_physical_inventory0')]) + self.action_confirm(cr,uid,[inventory.id]) assert inventory.state == 'confirm',"Inventory should be in 'Confirm' state" - self.action_done(cr,uid,[ref('stock_physical_inventory0')]) if inventory.inventory_line_id: for line in inventory.inventory_line_id: assert line.product_qty == 0.0,"Product Quantity should be Zero" assert len(inventory.move_ids) >= 1,"Move should be created after confirmed inventory" for move in inventory.move_ids: - assert move.product_qty == 1.0,"Product quantity of move is not correspond." - assert move.location_id.id == ref('location_inventory'),"Source location of move should be 'Inventory loss'" - assert move.location_dest_id.id == ref('stock_location_components'),"Destination location of move is not correspond." + assert move.location_id.id == ref('stock_location_components'),"Source location of move is not correspond." + assert move.location_dest_id.id == ref('location_inventory'),"Destination location of move should be 'Inventory loss'." - - I check the inventory after validation. + I validate the inventory after confirmation. - !python {model: stock.inventory}: | - inventory = self.browse(cr, uid, [ref('stock_physical_inventory0')]) - assert inventory[0].state == 'done',"Inventory should be in 'Done' state" + inventory = self.browse(cr, uid, [ref('stock_physical_inventory0')])[0] + self.action_done(cr,uid,[inventory.id]) + assert inventory.state == 'done',"Inventory should be in 'Done' state" + diff --git a/addons/stock/wizard/stock_fill_inventory.py b/addons/stock/wizard/stock_fill_inventory.py index 5c5e8964e9a..cd6aa59dc66 100644 --- a/addons/stock/wizard/stock_fill_inventory.py +++ b/addons/stock/wizard/stock_fill_inventory.py @@ -81,7 +81,7 @@ class stock_fill_inventory(osv.osv_memory): if fill_inventory.recursive: location_ids = location_obj.search(cr, uid, [('location_id', - 'child_of', [fill_inventory.location_id.id])], order="id", + 'child_of', [fill_inventory.location_id.id])], order="id", context=context) else: location_ids = [fill_inventory.location_id.id]