[IMP]stock: Improve the code for stock_physical_inventory.yml

bzr revid: dbr@tinyerp.com-20111208055841-d2igdvi02wf8y1kn
This commit is contained in:
DBR (OpenERP) 2011-12-08 11:28:41 +05:30
parent 4390c7e497
commit e835bc1125
2 changed files with 13 additions and 23 deletions

View File

@ -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"

View File

@ -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]