diff --git a/addons/stock/__openerp__.py b/addons/stock/__openerp__.py index ba196339ebd..ea1a5a0f13c 100644 --- a/addons/stock/__openerp__.py +++ b/addons/stock/__openerp__.py @@ -86,8 +86,7 @@ Thanks to the double entry management, the inventory controlling is powerful and 'test/stock_update.yml', 'test/stock_chain_location.yml', 'test/stock_demo_backorder.yml', - 'test/stock_scrap_move.yml', - 'test/stock_new_pack.yml', + #'test/stock_new_pack.yml', 'test/stock_report.yml', 'test/delete_stock.yml', 'test/cancel_stock.yml', diff --git a/addons/stock/test/stock_chain_location.yml b/addons/stock/test/stock_chain_location.yml index dc40e64a0e3..7f131f63b58 100644 --- a/addons/stock/test/stock_chain_location.yml +++ b/addons/stock/test/stock_chain_location.yml @@ -1,23 +1,65 @@ - In order to test chained locations, I update the stock of product. +- + I create stock production lot for product. +- + !record {model: stock.production.lot, id: stock_production_lot2}: + product_id: product.product_product_sprouting + date: !eval time.strftime('%Y-%m-%d %H:%M:%S') + name: 00000002 - I update product quantity and check the stock moves are properly done or not - - !python {model: stock.change.product.qty}: | - product = self.pool.get('product.product').browse(cr, uid, ref('product.product_product_sprouting')) - fields = {'location_id' : ref('convenience_location_stock'), 'new_quantity': 1, 'product_id': product.id} - ids = self.create(cr, uid, fields) - self.change_product_qty(cr, uid, [ids], {'active_model':'product.product', 'active_id': product.id, 'active_ids':[product.id]}) + !python {model: product.product}: | + change_qty = self.pool.get('stock.change.product.qty') + product = self.browse(cr, uid, ref('product.product_product_sprouting')) + ids = change_qty.create(cr, uid, {'location_id' : ref('convenience_location_stock'), 'new_quantity': 5, 'product_id': product.id,'prodlot_id': ref('stock_production_lot2')}) + change_qty.change_product_qty(cr, uid, [ids], {'active_model':'product.product', 'active_id': product.id, 'active_ids':[product.id]}) - I check stock moves of product. - !python {model: stock.move}: | ids = self.search(cr, uid, [('product_id','=',ref('product.product_product_sprouting'))]) - for i in self.browse(cr, uid, ids): - assert i.product_qty >= 1,"Product is not correspond" - if i.location_id.name == 'Inventory loss': - assert i.location_dest_id.name == 'Convenience Store',"Destination location must be 'Refrigerated Vehicles'" - if i.location_id.name == 'Convenience Store': - assert i.location_dest_id.name == 'Cold Storage',"Destination location must be 'Cold Storage' because the source location is 'Refrigerated Vehicles'" - if i.location_id.name == 'Cold Storage': - assert i.location_dest_id.name == 'Customers',"Destination location must be 'Customers' because the source location is 'Cold Storage'" + for move in self.browse(cr, uid, ids): + assert move.product_qty >= 1,"Product is not correspond" + if move.location_id.name == 'Inventory loss': + assert move.location_dest_id.name == 'Convenience Store',"Destination location must be 'Refrigerated Vehicles'" + if move.location_id.name == 'Convenience Store': + assert move.location_dest_id.name == 'Cold Storage',"Destination location must be 'Cold Storage' because the source location is 'Refrigerated Vehicles'" + if move.location_id.name == 'Cold Storage': + assert move.location_dest_id.name == 'Customers',"Destination location must be 'Customers' because the source location is 'Cold Storage'" +- + I create a move and scrap some quantities from it. +- + !python {model: stock.move.scrap}: | + ids = self.pool.get('stock.move').search(cr, uid, [('product_id','=',ref('product.product_product_sprouting')),('location_dest_id','=',ref('stock_location_customers'))]) + self.pool.get('stock.move').browse(cr, uid, ids)[0] + context = {'active_model':'stock.move', 'active_id':ids[0],'active_ids': ids} + values = self.default_get(cr, uid, ['location_id','product_id','product_uom','product_qty'], context) + scrap_ids = self.create(cr, uid, values) + self.move_scrap(cr, uid, [scrap_ids], context) +- + I check scraped move details. +- + !python {model: stock.move}: | + ids = self.search(cr, uid, [('product_id','=',ref('product.product_product_sprouting')),('location_dest_id','=',ref('stock_location_customers'))]) + for scrap_move in self.browse(cr, uid, ids): + if scrap_move.product_qty == 5.0 and scrap_move.location_dest_id == ref('stock_location_scrapped'): + assert scrap_move.state == 'done',"The scraped move should be in Done state" +- + I split a move in to different quantities. +- + !python {model: stock.move }: | + import time + ids = self.pool.get('stock.move').search(cr, uid, [('product_id','=',ref('product.product_product_sprouting')),('location_dest_id','=',ref('stock_location_customers'))]) + old_move=self.browse(cr,uid,ids)[0] + context = {'active_model': 'stock.move','active_id':ids[0],'active_ids': ids} + tracking_id = self.pool.get('stock.tracking').create(cr, uid, {'name': '0000007', 'date': time.strftime('%Y-%m-%d %H:%M:%S')}) + self.write(cr, uid, ids, {'tracking_id': tracking_id}) + split_obj=self.pool.get('stock.split.into') + split_id = split_obj.create(cr, uid, {'quantity': 1 }) + split_obj.split(cr, uid, [split_id], context) + all_ids = self.search(cr, uid, [('prodlot_id','=',ref('stock_production_lot2'))]) + new_move=self.browse(cr,uid,all_ids)[-1] + assert not old_move.tracking_id == new_move.tracking_id,"After spliting the move, new move should be created with new pack" + diff --git a/addons/stock/test/stock_demo_backorder.yml b/addons/stock/test/stock_demo_backorder.yml index 4ee7f2db608..3d9bf3d6803 100644 --- a/addons/stock/test/stock_demo_backorder.yml +++ b/addons/stock/test/stock_demo_backorder.yml @@ -15,27 +15,21 @@ location_dest_id: stock.stock_location_customers location_id: stock.stock_location_stock picking_id: stock_picking_1 -- | +- I make partial delivery for the delivery order. - !python {model: stock.picking}: | result = self.action_process(cr, uid, [ref('stock.stock_picking_1')], {})['res_id'] pick = self.pool.get('stock.partial.picking').browse(cr, uid, result, {}) - lobj = self.pool.get('stock.partial.picking.line') + pick_line = self.pool.get('stock.partial.picking.line') for line in pick.move_ids: if line.product_id.id == ref('product.product_product_cpu3'): - lobj.write(cr, uid, [line.id], { - 'quantity': 0.0 - }, {}) + pick_line.write(cr, uid, [line.id], {'quantity': 0.0}, {}) elif line.product_id.id == ref('product.product_product_cpu1'): - lobj.write(cr, uid, [line.id], { - 'quantity': 7.0 - }, {}) + pick_line.write(cr, uid, [line.id], {'quantity': 7.0}, {}) elif line.product_id.id == ref('product.product_product_fan2'): - lobj.write(cr, uid, [line.id], { - 'quantity': 3.0 - }, {}) - lobj.create(cr, uid, { + pick_line.write(cr, uid, [line.id], {'quantity': 3.0}, {}) + pick_line.create(cr, uid, { 'product_id': ref('product.product_product_pc1'), 'quantity': 2.0, 'product_uom': ref('product.product_uom_unit'), @@ -59,18 +53,17 @@ else: assert line.product_qty == 0.0, "Wrong quantity for %s back order" % (line.product_id.code,) - - After the partial picking of Delivery order I check the Backorder and stock moves. + After the partial picking of delivery order, I check the backorder and stock moves. - !python {model: stock.picking}: | - result = self.search(cr, uid, [('name','=','OUT/00001')]) - pick = self.pool.get('stock.picking').browse(cr, uid, result) + pick = self.browse(cr, uid, ref('stock.stock_picking_1')) stock = self.pool.get('stock.move') - assert pick[0].state == 'assigned',"After partial picking the remaining product's delivery order must be in 'Ready to process' state" - assert pick[0].backorder_id.state == 'done',"The backorder state should be 'Done'" - done_move = stock.search(cr, uid, [('picking_id','=',pick[0].backorder_id.id)]) - assign_move = stock.search(cr, uid, [('picking_id','=',pick[0].id)]) + assert pick.state == 'assigned',"After partial picking the remaining product's delivery order must be in 'Ready to process' state" + assert pick.backorder_id.state == 'done',"The backorder state should be 'Done'" + done_move = stock.search(cr, uid, [('picking_id','=',pick.backorder_id.id)]) + assign_move = stock.search(cr, uid, [('picking_id','=',pick.id)]) for move in stock.browse(cr, uid, done_move): - assert move.state == 'done',"Stock move of %s picking should be in 'Done' state"%(move.picking_id) + assert move.state == 'done',"Stock move of %s picking should be in 'Done' state"%(move.picking_id.name) for move in stock.browse(cr, uid, assign_move): - assert move.state == 'assigned' or 'draft',"Stock move of %s picking should be in 'Available' state"%(move.picking_id) + assert move.state == 'assigned' or 'draft',"Stock move of %s picking should be in 'Available' state"%(move.picking_id.name) diff --git a/addons/stock/test/stock_new_pack.yml b/addons/stock/test/stock_new_pack.yml index 371a3f493d0..264f9333757 100644 --- a/addons/stock/test/stock_new_pack.yml +++ b/addons/stock/test/stock_new_pack.yml @@ -5,7 +5,7 @@ name: 0000007 date: !eval time.strftime('%Y-%m-%d %H:%M:%S') - - I have to take one delivery order move and set the craeted pack. + I have to take one delivery order's move and set the created pack. - !record {model: stock.move, id: stock_move_3}: tracking_id: stock_tracking_0 diff --git a/addons/stock/test/stock_scrap_move.yml b/addons/stock/test/stock_scrap_move.yml deleted file mode 100644 index 7a6e6178701..00000000000 --- a/addons/stock/test/stock_scrap_move.yml +++ /dev/null @@ -1,24 +0,0 @@ -- - In order to test the scrap move, I create moves and scrap some quantities from those moves. -- - !record {model: stock.move, id: stock_move_4}: - product_id: product.product_product_fan2 - product_qty: 4.0 - location_dest_id: stock.stock_location_customers - location_id: stock.stock_location_stock -- - I create a move and scrap some quantities from it. -- - !python {model: stock.move.scrap}: | - context = {'active_model':'stock.move', 'active_id': ref('stock_move_4'), 'active_ids': [ref('stock_move_4')]} - values = self.default_get(cr, uid, ['location_id','product_id','product_uom','product_qty'], context) - ids = self.create(cr, uid, values) - self.move_scrap(cr, uid, [ids], context) -- - I check Scraped Move details. -- - !python {model: stock.move}: | - ids = self.search(cr, uid, [('product_id','=',ref('product.product_product_fan2'))]) - for scrap_move in self.browse(cr, uid, ids): - if scrap_move.product_qty == 4.0 and scrap_move.location_dest_id == ref('stock_location_scrapped'): - assert scrap_move.state == 'done',"The scraped move should be in Done state" diff --git a/addons/stock/test/stock_update.yml b/addons/stock/test/stock_update.yml index 70301d41f8a..69c621e9687 100644 --- a/addons/stock/test/stock_update.yml +++ b/addons/stock/test/stock_update.yml @@ -1,12 +1,12 @@ - I update the current stock of the product '[CPU2]High speed processor config'. - - I assignd the created location in to warehouse. + I assignd the location. - !record {model: stock.warehouse, id: stock.warehouse0}: lot_stock_id: stock_location_stock - - I create stock production lot for '[CPU2]High speed processor config' product. + I create stock production lot for product '[CPU2]High speed processor config'. - !record {model: stock.production.lot, id: stock_production_lot0}: product_id: product.product_product_cpu2 @@ -15,11 +15,11 @@ - I take '[CPU2]High speed processor config' product and with the help of 'Change Product Quantity' wizard update the product stock. - - !python {model: stock.change.product.qty}: | - product = self.pool.get('product.product').browse(cr, uid, ref('product.product_product_cpu2')) - fields = {'location_id' : ref('stock_location_stock'), 'new_quantity': 5, 'product_id': product.id, 'prodlot_id': ref('stock.stock_production_lot0')} - ids = self.create(cr, uid, fields) - self.change_product_qty(cr, uid, [ids], {'active_model':'product.product', 'active_id': product.id, 'active_ids':[product.id]}) + !python {model: product.product}: | + change_qty = self.pool.get('stock.change.product.qty') + product = self.browse(cr, uid, ref('product.product_product_cpu2')) + ids = change_qty.create(cr, uid, {'location_id' : ref('stock_location_stock'), 'new_quantity': 5, 'product_id': product.id, 'prodlot_id': ref('stock.stock_production_lot0')}) + change_qty.change_product_qty(cr, uid, [ids], {'active_model':'product.product', 'active_id': product.id, 'active_ids':[product.id]}) assert product.qty_available == 5,'Product Quantity is not Updated' - I trace the stock production lot for '[CPU2]High speed processor config' product. @@ -32,7 +32,6 @@ !python {model: stock.inventory.line}: | ids = self.search(cr, uid, [('product_id','=',ref('product.product_product_cpu2'))]) inventory = self.browse(cr, uid, ids)[0] - assert inventory.product_id.id == ref('product.product_product_cpu2'), 'Product is not correspond' assert inventory.product_qty == 5,'product Quantity is not correspond' assert inventory.location_id.id == ref('stock_location_stock'), 'Location is not correspond' assert inventory.state == 'done', 'State should be in Done state'