From afa694aa2d9b6383007f98066a2833452e3e7782 Mon Sep 17 00:00:00 2001 From: "DBR (OpenERP)" Date: Mon, 14 Nov 2011 13:14:11 +0530 Subject: [PATCH 01/35] [IMP] stock: Improve the test cases with the help of demo data bzr revid: dbr@tinyerp.com-20111114074411-tgo3tj2fl9oc10w4 --- addons/stock/test/stock_test.yml | 437 ++----------------------------- 1 file changed, 20 insertions(+), 417 deletions(-) diff --git a/addons/stock/test/stock_test.yml b/addons/stock/test/stock_test.yml index 63650ffeb38..99b11168b20 100644 --- a/addons/stock/test/stock_test.yml +++ b/addons/stock/test/stock_test.yml @@ -1,425 +1,28 @@ - - - In order to test the stock module, I will create product, - create physical inventory ,fill inventory lines from location,split inventory line into production lot + In order to test the stock module, I will update the current stock of the product. - - I create Stock Production Lot for product PC3 + I take one product and with the help of 'Change Product Quantity' wizard I update the product stock. + Changes the Product Quantity by making a Physical Inventory. - - !record {model: stock.production.lot, id: stock_production_lot0}: - product_id: product.product_product_pc3 - date: !eval time.strftime('%Y-%m-%d %H:%M:%S') - name: 0000001 + !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.stock_location_stock'), 'new_quantity': 2, '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]}) + assert product.qty_available == 2,'Product Quantity is not Updated' - - I trace the Stock Production Lot for product PC3. -- - !python {model: stock.production.lot }: | - self.action_traceability(cr,uid,[ref('stock_production_lot0')], {'lang': 'en_US', 'tz': False, 'active_model': 'ir.ui.menu', 'field': '', 'type': ''}) - -- - I create change product quantity for product PC3. -- - !record {model: stock.change.product.qty, id: stock_change_product_qty0}: - product_id: product.product_product_pc3 - new_quantity: 100 - location_id: stock.stock_location_stock - prodlot_id: stock.stock_production_lot0 - -- - I apply the new quantity on product PC3. -- - !python {model: stock.change.product.qty }: | - context = {"lang": 'en_US', "active_model": - "product.product", "active_ids": [ref("product.product_product_pc3")], "tz": False, "active_id":ref('product.product_product_pc3')} - self.default_get(cr, uid, ["prodlot_id", "location_id", "new_quantity", "product_id"], context) - self.fields_view_get(cr, uid, ref("stock.view_change_product_quantity"),"form", context) - self.change_product_qty(cr, uid, [ref("stock_change_product_qty0")], {"lang": 'en_US', "active_model": - "stock.change.product.qty", "active_ids": ref("product.product_product_pc3"), "tz": False, "active_id":ref('product.product_product_pc3')}) - -- - I check that the quantity on product PC3 is updated. -- - !python {model: product.product }: | - pro_obj = self.browse(cr, uid, ref("product.product_product_pc3")) - assert (pro_obj.qty_available >= 100) , "The quantity of PC3 is not updated!" - -- - I Read quantity on product PC3. -- - !python {model: stock.location }: | - self.read(cr, uid, [ref("stock.stock_location_stock")],['stock_real_value','stock_virtual'], {'lang': 'en_GB', 'tz': False, 'active_model': 'product.product', 'bin_size': True, 'active_ids': [ref("product.product_product_pc3")], 'product_id':ref("product.product_product_pc3"), 'active_id': ref("product.product_product_pc3")}) - -- - I Creating a chained stock.location record -- - !record {model: stock.location, id: stock_location_loc0}: - chained_auto_packing: auto - chained_delay: 0.0 - chained_location_id: stock.stock_location_customers - chained_location_type: fixed - location_id: stock.stock_location_company - name: chain location - parent_left: 2 - parent_right: 3 - usage: internal - -- - I create Product By location chart for stock.location.product Object. -- - !record {model: stock.location.product, id: stock_location_product0}: - from_date: '2011-07-01 00:00:00' - to_date: '2011-07-31 23:59:00' - -- - I open product chart. -- - !python {model: stock.location.product }: | - self.action_open_window(cr, uid, [ref("stock_location_product0")], {'lang': 'en_US', 'full': 1, 'tz': False, 'active_model': 'stock.location', 'search_default_in_location': 1, 'active_ids': [ref("stock.stock_location_stock")], 'active_id': ref("stock.stock_location_stock")}) - -- - I open product form from stock.location object . -- - !python {model: product.product }: | - self.fields_view_get(cr, uid, False, "tree", {'lang': 'en_US', 'full': 1, 'tz': False, 'active_model': 'stock.location', 'location': ref('stock.stock_location_stock'), 'search_default_in_location': 1, 'active_ids': [ref("stock.stock_location_stock")], 'active_id': ref("stock.stock_location_stock")}) - -- - I create change product standard price for product PC3. -- - !record {model: stock.change.standard.price, id: stock_change_standard_price0}: - new_price: 1515 - stock_account_input: account.a_recv - stock_account_output: account.a_pay - stock_journal: account.expenses_journal - enable_stock_in_out_acc: True - -- - I apply the new product standard price on product PC3. -- - !python {model: stock.change.standard.price }: | - context = {"lang": 'en_US', "active_model": - "product.product", "active_ids": [ref("product.product_product_pc3")], "tz": False, "active_id":ref('product.product_product_pc3')} - self.default_get(cr, uid, ["new_price"], context) - self.change_price(cr, uid, [ref("stock_change_product_qty0")], context) - -- - I create Physical Inventory for the products. -- - !record {model: stock.inventory, id: stock_inventory_physicalinventoy0}: - company_id: base.main_company - date: !eval time.strftime('%Y-%m-%d %H:%M:%S') - inventory_line_id: - - company_id: base.main_company - location_id: stock.stock_location_stock - product_id: product.product_product_pc3 - product_qty: 10.0 - product_uom: product.product_uom_unit - - company_id: base.main_company - location_id: stock.stock_location_stock - product_id: product.product_product_pc1 - product_qty: 10.0 - product_uom: product.product_uom_unit - name: Physical inventory - state: draft - -- - I create merge Inventory for the products. -- - !record {model: stock.inventory, id: stock_inventory_mergeinventoy0}: - company_id: base.main_company - date: !eval time.strftime('%Y-%m-%d %H:%M:%S') - inventory_line_id: - - company_id: base.main_company - location_id: stock.stock_location_stock - product_id: product.product_product_pc3 - product_qty: 20.0 - product_uom: product.product_uom_unit - - company_id: base.main_company - location_id: stock.stock_location_stock - product_id: product.product_product_pc1 - product_qty: 20.0 - product_uom: product.product_uom_unit - name: Physical inventory - state: draft - -- - I merge inventory . -- - !python {model: stock.inventory.merge}: | - context = {"lang": 'en_US', - "full": "1", "tz": False, "active_model": "stock.inventory", "active_ids": - [ref("stock_inventory_physicalinventoy0"), ref("stock_inventory_mergeinventoy0")], "active_id": ref("stock_inventory_physicalinventoy0"), } - self.fields_view_get(cr, uid, False, "form", context) - self.do_merge(cr, uid, [ref("stock_inventory_mergeinventoy0")], context) - -- - I create stock.inventory.line record. -- - !record {model: stock.inventory.line, id: stock_inventory_line}: - product_id: product.product_product_pc1 - product_uom: product.product_uom_unit - product_qty: 10 - inventory_id: stock_inventory_mergeinventoy0 - location_id: stock.stock_location_stock - -- - I Change a Product oF stock.inventory.line record. + I check Physical Inventory created. - !python {model: stock.inventory.line}: | - self.on_change_product_id(cr, uid, [ref("stock_inventory_line")], ref('stock.stock_location_stock'), ref('product.product_product_pc3'), False, False) - + 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 == 2,'product Quantity is not correspond' + assert inventory.location_id.id == ref('stock.stock_location_stock'), 'Location is not correspond' + assert inventory.state == 'done', 'State should be Done' - - I create stock.fill.inventory . + I check stock moves created. - - !record {model: stock.fill.inventory, id: stock_fill_inventory_0}: - location_id: stock.stock_location_stock - recursive: False - set_stock_zero: False - -- - I fill inventory for PC3. -- - !python {model: stock.fill.inventory}: | - context = {"lang": 'en_US',"full": "1", "tz": False, "active_model": "stock.inventory", "active_ids": - [ref("stock_inventory_physicalinventoy0")], "active_id": ref("stock_inventory_physicalinventoy0")} - self.view_init(cr, uid, ["set_stock_zero", "location_id", "recursive"], context) - self.fill_inventory(cr, uid, [ref("stock_fill_inventory_0")], context) - -- - I split the PC3 inventory line to create 5 PC3 with production lot 00002-stock-test -- - !record {model: stock.inventory.line.split, id: stock_inventory_line_0}: - line_ids: - - name: '00002-stock-test' - quantity: 5 - product_id: product.product_product_pc1 - product_uom: product.product_uom_unit - use_exist: False - qty: 10 -- - I confirm the split operation -- - !python {model: stock.inventory.line}: | - line_ids = self.search(cr, uid, [('inventory_id','=',ref('stock_inventory_physicalinventoy0')), - ('product_id','=',ref('product.product_product_pc1'))]) - assert line_ids, 'Inventory lines are missing' - self.pool.get('stock.inventory.line.split').split_lot(cr, uid, [ref("stock_inventory_line_0")], - {'active_model': 'stock.inventory.line', - 'active_ids': [line_ids[0]]}) -- - I confirm the Inventory for PC3. -- - !python {model: stock.inventory}: | - self.action_confirm(cr,uid,[ref('stock_inventory_physicalinventoy0')]) - self.action_done(cr,uid,[ref('stock_inventory_physicalinventoy0')]) -- - I cancel the Inventory for PC3. -- - !python {model: stock.inventory}: | - self.action_cancel_inventary(cr,uid,[ref('stock_inventory_physicalinventoy0')]) - -- - I change inventory state to draft for PC3. -- - !python {model: stock.inventory}: | - self.action_cancel_draft(cr,uid,[ref('stock_inventory_physicalinventoy0')]) - -- - In Order to test the picking I create picking with move lines. -- - !record {model: stock.picking, id: stock_picking_0}: - name: test_picking - address_id: base.res_partner_address_4 - company_id: base.main_company - date: !eval time.strftime('%Y-%m-%d %H:%M:%S') - invoice_state: 2binvoiced - move_lines: - - company_id: base.main_company - date: !eval time.strftime('%Y-%m-%d %H:%M:%S') - location_dest_id: stock.stock_location_loc0 - location_id: stock.stock_location_stock - name: PC3 - product_id: product.product_product_pc3 - product_qty: 100.0 - product_uom: product.product_uom_unit - date: !eval time.strftime('%Y-%m-%d %H:%M:%S') - product_uos_qty: 100.0 - move_type: direct - type: out - -- - I split the picking with a first batch of 20 PCs -- - !python {model: stock.picking }: | - pick=self.browse(cr,uid,ref('stock_picking_0')) - split_obj=self.pool.get('stock.split.into') - partial_datas={} - move=pick.move_lines[0] - partial_datas= { - 'quantity': 20, - } - split_id = self.pool.get('stock.split.into').create(cr, uid, partial_datas) - split_obj.split(cr, uid, [split_id], {"lang": "en_US", "tz": - False, "active_model": "stock.move", "active_ids": [move.id], - "active_id": move.id, }) - -- - I click on draft_force_assign on picking. -- - !python {model: stock.picking}: | - self.draft_force_assign(cr, uid, [ref("stock_picking_0")], {"lang": "en_US", "active_model": - "ir.ui.menu", "tz": False, "search_default_confirmed": 1, "contact_display": - "partner", "active_ids": [ref("stock.menu_action_picking_tree6")], "active_id": - ref("stock.menu_action_picking_tree6"), }) - -- - I click on action_assign on picking. -- - !python {model: stock.picking}: | - self.action_assign(cr, uid, [ref("stock_picking_0")], {"lang": "en_US", "active_model": - "ir.ui.menu", "tz": False, "search_default_confirmed": 1, "contact_display": - "partner", "active_ids": [ref("stock.menu_action_picking_tree6")], "active_id": - ref("stock.menu_action_picking_tree6"), }) - -- - I process the partial picking with 20 PCE -- - !python {model: stock.picking }: | - pick = self.browse(cr,uid,ref('stock_picking_0')) - stock_partial_move = self.pool.get('stock.partial.move') - partial_id = stock_partial_move.create(cr, uid, {}, - context={'active_model': 'stock.move', - 'active_ids': [x.id for x in pick.move_lines]}) - stock_partial_move.do_partial(cr, uid, [partial_id]) -- - I Performing an osv_memory action split_lot on module stock.move.split -- - - !python {model: stock.picking }: | - split_obj=self.pool.get('stock.move.split') - split_move_lines=self.pool.get('stock.move.split.lines') - pick=self.browse(cr,uid,ref('stock_picking_0')) - partial_datas={} - move=pick.move_lines[0] - partial_datas= { - 'product_id': move.product_id.id, - 'qty': 80, - 'product_uom': move.product_uom.id, - 'use_exist': move.picking_id and move.picking_id.type=='out' and True or False - } - split_id = self.pool.get('stock.move.split').create(cr, uid, partial_datas, context={}) - split_move_data= { - 'lot_id': split_id, - 'quantity': 10, - 'name': 'lot', - } - split_move_id = split_move_lines.create(cr, uid, split_move_data, context={}) - split_obj.default_get(cr, uid, ["product_id", "product_uom", "line_exist_ids", "qty", - "line_ids", "use_exist"], {'lang': 'en_US', 'default_location_dest_id': ref('stock.stock_location_stock'), 'tz': False, 'active_model': 'stock.move', 'search_default_receive': 1, 'product_receive': True, 'active_ids': [move.id], 'default_location_id': ref('stock.stock_location_locations'), 'active_id': move.id}) - split_obj.split_lot(cr, uid, [split_id], context={"lang": "en_US", "tz": - False, "active_model": "stock.move", "scrap": True, "active_ids": [move.id], - "active_id": move.id, }) - -- - I Performed an osv_memory action move_scrap on module stock.move.scrap -- - !python {model: stock.picking }: | - location_obj = self.pool.get('stock.location') - scrpaed_location_ids = location_obj.search(cr, uid, [('scrap_location','=',True)]) - pick=self.browse(cr,uid,ref('stock_picking_0')) - scrap_obj=self.pool.get('stock.move.scrap') - partial_datas={} - move=pick.move_lines[0] - partial_datas= { - 'product_id': move.product_id.id, - 'location_id': scrpaed_location_ids[0], - 'product_qty': 1, - 'product_uom': move.product_uom.id, - } - scrap_id = scrap_obj.create(cr, uid, partial_datas) - context = {"lang": "en_US", "tz": False, "active_model": "stock.move", - "scrap": True, "active_ids": [move.id], "active_id": move.id, } - scrap_obj.default_get(cr, uid, ["location_id", "product_id", "product_uom", "product_qty"], context) - scrap_obj.move_scrap(cr, uid, [scrap_id], context) - -- - I Performed an osv_memory do move consume on module stock.move.consume -- - !python {model: stock.picking }: | - location_obj = self.pool.get('stock.location') - scrpaed_location_ids = location_obj.search(cr, uid, [('scrap_location','=',True)]) - pick=self.browse(cr,uid,ref('stock_picking_0')) - consume_obj=self.pool.get('stock.move.consume') - partial_datas={} - move=pick.move_lines[0] - partial_datas= { - 'product_id': move.product_id.id, - 'location_id': scrpaed_location_ids[0], - 'product_qty': 1, - 'product_uom': move.product_uom.id, - } - context = {"lang": "en_US", "tz": False, "active_model": "stock.move", - "scrap": True, "active_ids": [move.id], "active_id": move.id, } - consume_id = consume_obj.create(cr, uid, partial_datas) - consume_obj.default_get(cr, uid, ["location_id", "product_id", "product_uom", "product_qty"], context) - consume_obj.do_move_consume(cr, uid, [consume_id], context) - -- - I process the picking with the 80 remaining PCs -- - !python {model: stock.picking}: | - stock_partial_picking = self.pool.get('stock.partial.picking') - partial_id = stock_partial_picking.create(cr, uid, {}, - context={'active_model': 'stock.picking', - 'active_ids': [ref('stock_picking_0')]}) - stock_partial_picking.do_partial(cr, uid, [partial_id]) -- - I Performing an osv_memory action create_invoice on module stock.invoice.onshipping -- - !python {model: stock.invoice.onshipping}: | - invoice_line_id = self.create(cr, uid,{}, {"lang": 'en_US', "active_model": - "stock.picking", "active_ids": [ref("stock_picking_0")], "tz": False, "active_id":ref("stock_picking_0")}) - self.open_invoice(cr, uid, [invoice_line_id], {"lang": "en_US", - "search_default_available": 1, "inv_type": "in_invoice" , "tz": False, "active_model": "stock.picking", - "contact_display": "partner_address", "active_ids": [ref("stock_picking_0")], - "active_id": ref("stock_picking_0")}) - self._get_journal_id(cr, uid, {"lang": "en_US", "search_default_available": 1, "tz": False, "active_model": "stock.picking", - "contact_display": "partner_address", "active_ids": [ref("stock_picking_0")], - "active_id": ref("stock_picking_0"), }) - -- - I create a record of stock.picking and unlink a record -- - !python {model: stock.picking}: | - copy_id = self.copy(cr, uid, (ref("stock_picking_0"))) - ctx = {"lang": "en_US", "active_model": - "ir.ui.menu", "tz": False, "search_default_confirmed": 1, "contact_display": - "partner", "active_ids": [ref("stock.menu_action_picking_tree6")], "active_id": - ref("stock.menu_action_picking_tree6"), } - self.draft_force_assign(cr, uid, [copy_id], ctx) - self.unlink(cr, uid, [copy_id], ctx) - -- - I create a record of stock.picking and cancel a record -- - !python {model: stock.picking}: | - copy_id = self.copy(cr, uid, (ref("stock_picking_0"))) - self.draft_validate(cr, uid, [copy_id], {"lang": "en_US", "search_default_available": - 1, "tz": False, "active_model": "ir.ui.menu", "contact_display": "partner_address", - "active_ids": [ref("stock.menu_action_picking_tree4")], "active_id": ref("stock.menu_action_picking_tree4"), - }) - self.allow_cancel(cr, uid, [copy_id], context= None) - -- - I process a copy of the picking and I return it -- - !python {model: stock.picking}: | - copy_id = self.copy(cr, uid, (ref("stock_picking_0"))) - self.draft_force_assign(cr, uid, [copy_id]) - self.force_assign(cr, uid, [copy_id]) - stock_partial_picking = self.pool.get('stock.partial.picking') - context = {'active_model': 'stock.picking', - 'active_ids': [copy_id], - 'active_id': copy_id} - partial_id = stock_partial_picking.create(cr, uid, {}, context=context) - stock_partial_picking.do_partial(cr, uid, [partial_id], context) - return_pick_id = self.pool.get('stock.return.picking').create(cr, uid,{}, context) - self.pool.get('stock.return.picking').create_returns(cr, uid, [return_pick_id], context) + !python {model: stock.move}: | + ids = self.search(cr, uid, [('product_id','=',ref('product.product_product_cpu2'))]) + assert [x.state for x in self.browse(cr, uid, ids) if x.state == 'done'], 'stock moves should be done!' From ef580690d7bd0121b13780685c5d4493d8912dbe Mon Sep 17 00:00:00 2001 From: "DBR (OpenERP)" Date: Thu, 17 Nov 2011 16:48:42 +0530 Subject: [PATCH 02/35] [IMP]stock: Improve test code for production lot bzr revid: dbr@tinyerp.com-20111117111842-urwdxbz3x8ogrsmt --- addons/stock/test/stock_test.yml | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/addons/stock/test/stock_test.yml b/addons/stock/test/stock_test.yml index 99b11168b20..67a46dc3523 100644 --- a/addons/stock/test/stock_test.yml +++ b/addons/stock/test/stock_test.yml @@ -1,12 +1,24 @@ - In order to test the stock module, I will update the current stock of the product. - - I take one product and with the help of 'Change Product Quantity' wizard I update the product stock. + I create Stock Production Lot for product CPU2 +- + !record {model: stock.production.lot, id: stock_production_lot0}: + product_id: product.product_product_cpu2 + date: !eval time.strftime('%Y-%m-%d %H:%M:%S') + name: 0000001 +- + I trace the Stock Production Lot for product CPU2 +- + !python {model: stock.production.lot }: | + self.action_traceability(cr,uid,[ref('stock_production_lot0')], {'lang': 'en_US', 'tz': False, 'active_model': 'ir.ui.menu', 'field': '', 'type': ''}) +- + I take one product CPU2 and with the help of 'Change Product Quantity' wizard I update the product stock. Changes the Product Quantity by making a Physical Inventory. - !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.stock_location_stock'), 'new_quantity': 2, 'product_id': product.id} + fields = {'location_id' : ref('stock.stock_location_stock'), 'new_quantity': 2, '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]}) assert product.qty_available == 2,'Product Quantity is not Updated' @@ -19,7 +31,7 @@ assert inventory.product_id.id == ref('product.product_product_cpu2'), 'Product is not correspond' assert inventory.product_qty == 2,'product Quantity is not correspond' assert inventory.location_id.id == ref('stock.stock_location_stock'), 'Location is not correspond' - assert inventory.state == 'done', 'State should be Done' + assert inventory.state == 'done', 'State should be in Done state' - I check stock moves created. - From 1555e0717cc5f8a71ab14507aa9571b104c5713a Mon Sep 17 00:00:00 2001 From: "DBR (OpenERP)" Date: Thu, 17 Nov 2011 18:56:57 +0530 Subject: [PATCH 03/35] [IMP]stock: Improve the test cases for chain location bzr revid: dbr@tinyerp.com-20111117132657-gpsy5x4av19voj4z --- addons/stock/__openerp__.py | 4 ++-- addons/stock/stock_demo_picking.yml | 6 ++++++ addons/stock/test/stock_test.yml | 22 ++++++++++++++++++++-- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/addons/stock/__openerp__.py b/addons/stock/__openerp__.py index 73215505177..d6207a436cb 100644 --- a/addons/stock/__openerp__.py +++ b/addons/stock/__openerp__.py @@ -83,8 +83,8 @@ Thanks to the double entry management, the inventory controlling is powerful and ], 'test': [ 'test/stock_test.yml', - 'test/stock_report.yml', - 'test/stock_test_wizard.yml', + #'test/stock_report.yml', + #'test/stock_test_wizard.yml', 'test/stock_demo_backorder.yml' ], 'installable': True, diff --git a/addons/stock/stock_demo_picking.yml b/addons/stock/stock_demo_picking.yml index 6301ab7a0cb..62732c82cdb 100644 --- a/addons/stock/stock_demo_picking.yml +++ b/addons/stock/stock_demo_picking.yml @@ -1,8 +1,12 @@ +- + Created a picking - !record {model: stock.picking, id: stock_picking_1}: type: out company_id: base.main_company address_id: res_partner_address_fabien0 +- + Created a Move - !record {model: stock.move, id: stock_move_1}: product_id: product.product_product_cpu1 @@ -13,6 +17,8 @@ location_id: stock.stock_location_stock name: CPU1, Processor AMD Athlon XP 1800 picking_id: stock_picking_1 +- + Created another Move - !record {model: stock.move, id: stock_move_2}: product_id: product.product_product_cpu3 diff --git a/addons/stock/test/stock_test.yml b/addons/stock/test/stock_test.yml index 67a46dc3523..9f0abf101fb 100644 --- a/addons/stock/test/stock_test.yml +++ b/addons/stock/test/stock_test.yml @@ -1,5 +1,22 @@ - In order to test the stock module, I will update the current stock of the product. +- + I Creating a location record for test the chained location flow. +- + !record {model: stock.location, id: stock_location_loc0}: + chained_auto_packing: auto + chained_delay: 0.0 + chained_location_type: none + location_id: stock.stock_location_company + name: chain location + parent_left: 2 + parent_right: 3 + usage: internal +- + I assignd the created location in to warehouse. +- + !record {model: stock.warehouse, id: stock.warehouse0}: + lot_stock_id: stock_location_loc0 - I create Stock Production Lot for product CPU2 - @@ -17,8 +34,9 @@ Changes the Product Quantity by making a Physical Inventory. - !python {model: stock.change.product.qty}: | + #stock.stock_location_stock product = self.pool.get('product.product').browse(cr, uid, ref('product.product_product_cpu2')) - fields = {'location_id' : ref('stock.stock_location_stock'), 'new_quantity': 2, 'product_id': product.id, 'prodlot_id': ref('stock.stock_production_lot0')} + fields = {'location_id' : ref('stock_location_loc0'), 'new_quantity': 2, '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]}) assert product.qty_available == 2,'Product Quantity is not Updated' @@ -30,7 +48,7 @@ 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 == 2,'product Quantity is not correspond' - assert inventory.location_id.id == ref('stock.stock_location_stock'), 'Location is not correspond' + assert inventory.location_id.id == ref('stock_location_loc0'), 'Location is not correspond' assert inventory.state == 'done', 'State should be in Done state' - I check stock moves created. From c76cc5f27fd0479664856012288e9386c41913fa Mon Sep 17 00:00:00 2001 From: "DBR (OpenERP)" Date: Fri, 18 Nov 2011 12:04:42 +0530 Subject: [PATCH 05/35] [MOVE]stock : Move the stock_test.yml in to stock/test/process/update_stock.yml bzr revid: dbr@tinyerp.com-20111118063442-uxlmw1nq1vjzz2x3 --- addons/stock/__openerp__.py | 2 +- addons/stock/test/{stock_test.yml => process/update_stock.yml} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename addons/stock/test/{stock_test.yml => process/update_stock.yml} (100%) diff --git a/addons/stock/__openerp__.py b/addons/stock/__openerp__.py index d6207a436cb..f9e9f58a5d4 100644 --- a/addons/stock/__openerp__.py +++ b/addons/stock/__openerp__.py @@ -82,7 +82,7 @@ Thanks to the double entry management, the inventory controlling is powerful and "board_warehouse_view.xml", ], 'test': [ - 'test/stock_test.yml', + 'test/process/update_stock.yml', #'test/stock_report.yml', #'test/stock_test_wizard.yml', 'test/stock_demo_backorder.yml' diff --git a/addons/stock/test/stock_test.yml b/addons/stock/test/process/update_stock.yml similarity index 100% rename from addons/stock/test/stock_test.yml rename to addons/stock/test/process/update_stock.yml From b33ff65887efd7e4c786e6decdaa29d119bb91ad Mon Sep 17 00:00:00 2001 From: "DBR (OpenERP)" Date: Fri, 18 Nov 2011 19:04:02 +0530 Subject: [PATCH 06/35] [IMP]stock: Improve the demo data for imp test cases of chain location bzr revid: dbr@tinyerp.com-20111118133402-5e3x1l21jmbi047o --- addons/stock/__openerp__.py | 3 ++- addons/stock/stock_demo.xml | 8 ++++++++ .../{ => process}/stock_demo_backorder.yml | 0 addons/stock/test/process/update_stock.yml | 18 +++++++----------- 4 files changed, 17 insertions(+), 12 deletions(-) rename addons/stock/test/{ => process}/stock_demo_backorder.yml (100%) diff --git a/addons/stock/__openerp__.py b/addons/stock/__openerp__.py index f9e9f58a5d4..951f2e81ac8 100644 --- a/addons/stock/__openerp__.py +++ b/addons/stock/__openerp__.py @@ -85,7 +85,8 @@ Thanks to the double entry management, the inventory controlling is powerful and 'test/process/update_stock.yml', #'test/stock_report.yml', #'test/stock_test_wizard.yml', - 'test/stock_demo_backorder.yml' + 'test/process/stock_demo_backorder.yml', + #'test/process/stock_incoming_shipment.yml', ], 'installable': True, 'active': False, diff --git a/addons/stock/stock_demo.xml b/addons/stock/stock_demo.xml index ca897ced8ef..8cacdba9919 100644 --- a/addons/stock/stock_demo.xml +++ b/addons/stock/stock_demo.xml @@ -9,6 +9,14 @@ + + Cold Storage + + fixed + + auto + internal + IT Suppliers diff --git a/addons/stock/test/stock_demo_backorder.yml b/addons/stock/test/process/stock_demo_backorder.yml similarity index 100% rename from addons/stock/test/stock_demo_backorder.yml rename to addons/stock/test/process/stock_demo_backorder.yml diff --git a/addons/stock/test/process/update_stock.yml b/addons/stock/test/process/update_stock.yml index 9f0abf101fb..cea7b39cb07 100644 --- a/addons/stock/test/process/update_stock.yml +++ b/addons/stock/test/process/update_stock.yml @@ -1,22 +1,18 @@ - In order to test the stock module, I will update the current stock of the product. - - I Creating a location record for test the chained location flow. + I assign a chain location cold storage to test the chained location flow. - - !record {model: stock.location, id: stock_location_loc0}: + !record {model: stock.location, id: stock_location_stock}: chained_auto_packing: auto - chained_delay: 0.0 - chained_location_type: none - location_id: stock.stock_location_company - name: chain location - parent_left: 2 - parent_right: 3 + chained_location_type: fixed + chained_location_id: stock.chain_location_1 usage: internal - I assignd the created location in to warehouse. - !record {model: stock.warehouse, id: stock.warehouse0}: - lot_stock_id: stock_location_loc0 + lot_stock_id: stock_location_stock - I create Stock Production Lot for product CPU2 - @@ -36,7 +32,7 @@ !python {model: stock.change.product.qty}: | #stock.stock_location_stock product = self.pool.get('product.product').browse(cr, uid, ref('product.product_product_cpu2')) - fields = {'location_id' : ref('stock_location_loc0'), 'new_quantity': 2, 'product_id': product.id, 'prodlot_id': ref('stock.stock_production_lot0')} + fields = {'location_id' : ref('stock_location_stock'), 'new_quantity': 2, '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]}) assert product.qty_available == 2,'Product Quantity is not Updated' @@ -48,7 +44,7 @@ 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 == 2,'product Quantity is not correspond' - assert inventory.location_id.id == ref('stock_location_loc0'), 'Location 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' - I check stock moves created. From a169f9ee171727021c2749237678ff356ca00f96 Mon Sep 17 00:00:00 2001 From: "DBR (OpenERP)" Date: Mon, 21 Nov 2011 16:35:02 +0530 Subject: [PATCH 07/35] [IMP]stock: Improve the test cases and some demo data bzr revid: dbr@tinyerp.com-20111121110502-8ptqo3uf325rvtnb --- addons/product/product_demo.xml | 13 +++++++++ addons/stock/__openerp__.py | 2 +- addons/stock/stock_data.xml | 18 ++++++++++++ addons/stock/test/process/update_stock.yml | 34 +++++++++++++++++----- 4 files changed, 58 insertions(+), 9 deletions(-) diff --git a/addons/product/product_demo.xml b/addons/product/product_demo.xml index 3aebec13715..775f24a101a 100644 --- a/addons/product/product_demo.xml +++ b/addons/product/product_demo.xml @@ -321,6 +321,19 @@ product + + Sprouting + buy + 250.0 + 200.0 + + + make_to_stock + 7.0 + Sprouting Foods + product + + TOW1 37.5 diff --git a/addons/stock/__openerp__.py b/addons/stock/__openerp__.py index 951f2e81ac8..e60c3edf90a 100644 --- a/addons/stock/__openerp__.py +++ b/addons/stock/__openerp__.py @@ -85,7 +85,7 @@ Thanks to the double entry management, the inventory controlling is powerful and 'test/process/update_stock.yml', #'test/stock_report.yml', #'test/stock_test_wizard.yml', - 'test/process/stock_demo_backorder.yml', + #'test/process/stock_demo_backorder.yml', #'test/process/stock_incoming_shipment.yml', ], 'installable': True, diff --git a/addons/stock/stock_data.xml b/addons/stock/stock_data.xml index c0c872e99f2..3f8fd8113ce 100644 --- a/addons/stock/stock_data.xml +++ b/addons/stock/stock_data.xml @@ -90,6 +90,14 @@ view + + Cold Storage + + fixed + + auto + internal + Delivery Orders @@ -103,6 +111,16 @@ out + + + Refrigerated Vehicles + + auto + fixed + internal + + + Stock diff --git a/addons/stock/test/process/update_stock.yml b/addons/stock/test/process/update_stock.yml index cea7b39cb07..cd3f48bc19e 100644 --- a/addons/stock/test/process/update_stock.yml +++ b/addons/stock/test/process/update_stock.yml @@ -1,13 +1,5 @@ - In order to test the stock module, I will update the current stock of the product. -- - I assign a chain location cold storage to test the chained location flow. -- - !record {model: stock.location, id: stock_location_stock}: - chained_auto_packing: auto - chained_location_type: fixed - chained_location_id: stock.chain_location_1 - usage: internal - I assignd the created location in to warehouse. - @@ -52,3 +44,29 @@ !python {model: stock.move}: | ids = self.search(cr, uid, [('product_id','=',ref('product.product_product_cpu2'))]) assert [x.state for x in self.browse(cr, uid, ids) if x.state == 'done'], 'stock moves should be done!' + +- + Now for the test chain location functionality, + I update product 'Sprouting Foods' with the help of 'Change Product Quantity' wizard + and assign a location 'Refrigerated Vehicles' to test the chained location flow. +- + !python {model: stock.change.product.qty}: | + product = self.pool.get('product.product').browse(cr, uid, ref('product.product_product_sprouting')) + fields = {'location_id' : ref('refrigerate_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]}) + +- + I check stock moves of product 'Sprouting Foods'. +- + !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 == 'Refrigerated Vehicles',"Destination location must be 'Refrigerated Vehicles'" + if i.location_id.name == 'Refrigerated Vehicles': + 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'" + From 9b921998af4de13833e7280134f9b4fe7a03accf Mon Sep 17 00:00:00 2001 From: "DBR (OpenERP)" Date: Mon, 21 Nov 2011 18:37:18 +0530 Subject: [PATCH 08/35] [ADD,IMP]stock : Add a yml file for define test cases of scrap move Improve the stock_demo_backorder.yml file bzr revid: dbr@tinyerp.com-20111121130718-3q67e1pyafcrzttk --- addons/stock/__openerp__.py | 4 ++-- addons/stock/test/process/scrap_move.yml | 24 +++++++++++++++++++ .../test/process/stock_demo_backorder.yml | 3 --- 3 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 addons/stock/test/process/scrap_move.yml diff --git a/addons/stock/__openerp__.py b/addons/stock/__openerp__.py index e60c3edf90a..ffe888c1d2b 100644 --- a/addons/stock/__openerp__.py +++ b/addons/stock/__openerp__.py @@ -85,8 +85,8 @@ Thanks to the double entry management, the inventory controlling is powerful and 'test/process/update_stock.yml', #'test/stock_report.yml', #'test/stock_test_wizard.yml', - #'test/process/stock_demo_backorder.yml', - #'test/process/stock_incoming_shipment.yml', + 'test/process/stock_demo_backorder.yml', + 'test/process/scrap_move.yml', ], 'installable': True, 'active': False, diff --git a/addons/stock/test/process/scrap_move.yml b/addons/stock/test/process/scrap_move.yml new file mode 100644 index 00000000000..129982586e1 --- /dev/null +++ b/addons/stock/test/process/scrap_move.yml @@ -0,0 +1,24 @@ +- + In order to test the scrap move, I add create a new move line in draft state with FAN2 +- + !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 +- + Now, withe help of 'Scrap Move' wizard, I scap the move of same Quantity. +- + !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/process/stock_demo_backorder.yml b/addons/stock/test/process/stock_demo_backorder.yml index 986a59c7349..8b17c6380c9 100644 --- a/addons/stock/test/process/stock_demo_backorder.yml +++ b/addons/stock/test/process/stock_demo_backorder.yml @@ -11,12 +11,9 @@ - !record {model: stock.move, id: stock_move_3}: product_id: product.product_product_fan2 - product_uom: product.product_uom_unit - product_uos_qty: 7.0 product_qty: 7.0 location_dest_id: stock.stock_location_customers location_id: stock.stock_location_stock - name: CPU3, Processor AMD Athlon XP 1800 picking_id: stock_picking_1 - | I click on 'Process Now' to process the delivery order and I change quantities to: From dd7a468a16a6fafa997c01da70b70483f6dc1a17 Mon Sep 17 00:00:00 2001 From: "DBR (OpenERP)" Date: Mon, 28 Nov 2011 16:13:59 +0530 Subject: [PATCH 09/35] [IMP]stock: Improve the test cases and statements of test bzr revid: dbr@tinyerp.com-20111128104359-k90im8ibg9ujt3jk --- addons/stock/test/process/scrap_move.yml | 2 +- .../test/process/stock_demo_backorder.yml | 31 +++++++++++---- addons/stock/test/process/update_stock.yml | 39 ++++++++++++------- 3 files changed, 49 insertions(+), 23 deletions(-) diff --git a/addons/stock/test/process/scrap_move.yml b/addons/stock/test/process/scrap_move.yml index 129982586e1..1b942d07b3d 100644 --- a/addons/stock/test/process/scrap_move.yml +++ b/addons/stock/test/process/scrap_move.yml @@ -7,7 +7,7 @@ location_dest_id: stock.stock_location_customers location_id: stock.stock_location_stock - - Now, withe help of 'Scrap Move' wizard, I scap the move of same Quantity. + Now, with the help of 'Scrap Move' wizard, I scap the move of same Quantity. - !python {model: stock.move.scrap}: | context = {'active_model':'stock.move', 'active_id': ref('stock_move_4'), 'active_ids': [ref('stock_move_4')]} diff --git a/addons/stock/test/process/stock_demo_backorder.yml b/addons/stock/test/process/stock_demo_backorder.yml index 8b17c6380c9..3da67e369f2 100644 --- a/addons/stock/test/process/stock_demo_backorder.yml +++ b/addons/stock/test/process/stock_demo_backorder.yml @@ -1,13 +1,15 @@ -- - In order to test partial delivery and back orders, I will use a delivery order with 5 CPU1 and 5 CPU3 - - I confirm and force the availability of all products on the picking OUT001 -- + In order to test partial delivery and back orders, + I select a delivery order of CPU1 and CPU3 product each contain five quantities. +- + I confirm the picking 'OUT001' and make it available . +- !python {model: stock.picking}: | self.draft_force_assign(cr, uid, [ref('stock.stock_picking_1')], {}) self.force_assign(cr, uid, [ref('stock.stock_picking_1')], {}) - - After having confirmed the picking and its two lines, I add a new move line in draft state with 7 FAN2 + After confirmed the picking and its two lines, + I add a new move line in draft state with 'FAN2' of seven quantities. - !record {model: stock.move, id: stock_move_3}: product_id: product.product_product_fan2 @@ -17,7 +19,7 @@ picking_id: stock_picking_1 - | I click on 'Process Now' to process the delivery order and I change quantities to: - 7 CPU1, 0 CPU3, 3 FAN2 and a new product of 4 PC1 + seven for CPU1, zero for CPU3, three for FAN2 and a new product PC1 for four quantites for test the partial delivery. - !python {model: stock.picking}: | result = self.action_process(cr, uid, [ref('stock.stock_picking_1')], {})['res_id'] @@ -46,7 +48,7 @@ }, {}) self.pool.get('stock.partial.picking').do_partial(cr, uid, [result], {}) - - I test that the back order contains 5 CPU3, 4 FAN2 and nothing else + I test that the back order contains five CPU3 and four FAN2. - !python {model: stock.picking}: | pick = self.browse(cr, uid, ref('stock.stock_picking_1'), {}) @@ -59,4 +61,19 @@ assert line.product_qty == 0.0, "Wrong quantity for PC1 back order" else: assert line.product_qty == 0.0, "Wrong quantity for %s back order" % (line.product_id.code,) +- + After the partial picking I check the delivery order or 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) + 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)]) + 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) + 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) diff --git a/addons/stock/test/process/update_stock.yml b/addons/stock/test/process/update_stock.yml index cd3f48bc19e..7117fe669e8 100644 --- a/addons/stock/test/process/update_stock.yml +++ b/addons/stock/test/process/update_stock.yml @@ -1,33 +1,32 @@ - In order to test the stock module, I will update the current stock of the product. -- +- I assignd the created location in to warehouse. -- +- !record {model: stock.warehouse, id: stock.warehouse0}: lot_stock_id: stock_location_stock - - I create Stock Production Lot for product CPU2 + I create stock production lot for product CPU2 - !record {model: stock.production.lot, id: stock_production_lot0}: product_id: product.product_product_cpu2 date: !eval time.strftime('%Y-%m-%d %H:%M:%S') name: 0000001 -- - I trace the Stock Production Lot for product CPU2 -- - !python {model: stock.production.lot }: | - self.action_traceability(cr,uid,[ref('stock_production_lot0')], {'lang': 'en_US', 'tz': False, 'active_model': 'ir.ui.menu', 'field': '', 'type': ''}) - I take one product CPU2 and with the help of 'Change Product Quantity' wizard I update the product stock. Changes the Product Quantity by making a Physical Inventory. - !python {model: stock.change.product.qty}: | - #stock.stock_location_stock product = self.pool.get('product.product').browse(cr, uid, ref('product.product_product_cpu2')) fields = {'location_id' : ref('stock_location_stock'), 'new_quantity': 2, '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]}) assert product.qty_available == 2,'Product Quantity is not Updated' +- + I trace the Stock Production Lot for product CPU2 +- + !python {model: stock.production.lot }: | + self.action_traceability(cr,uid,[ref('stock_production_lot0')], {'lang': 'en_US', 'tz': False, 'active_model': 'ir.ui.menu', 'field': '', 'type': ''}) - I check Physical Inventory created. - @@ -44,15 +43,21 @@ !python {model: stock.move}: | ids = self.search(cr, uid, [('product_id','=',ref('product.product_product_cpu2'))]) assert [x.state for x in self.browse(cr, uid, ids) if x.state == 'done'], 'stock moves should be done!' - -- - Now for the test chain location functionality, +- + For the test chain location functionality, + I create stock production lot for product 'Sprouting Foods'. +- + !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: 0000002 +- I update product 'Sprouting Foods' with the help of 'Change Product Quantity' wizard and assign a location 'Refrigerated Vehicles' to test the chained location flow. -- +- !python {model: stock.change.product.qty}: | product = self.pool.get('product.product').browse(cr, uid, ref('product.product_product_sprouting')) - fields = {'location_id' : ref('refrigerate_location_stock'), 'new_quantity': 1, 'product_id': product.id} + fields = {'location_id' : ref('refrigerate_location_stock'), 'new_quantity': 1, 'product_id': product.id, 'prodlot_id': ref('stock.stock_production_lot2')} 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]}) @@ -69,4 +74,8 @@ 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'" - +- + I trace the stock production lot for product 'Sprouting Foods' +- + !python {model: stock.production.lot }: | + self.action_traceability(cr,uid,[ref('stock_production_lot2')], {'active_model': 'ir.ui.menu', 'field': '', 'type': ''}) From 70851e4aa8501bd95cc80b9931f6c1e3b9a570c7 Mon Sep 17 00:00:00 2001 From: "DBR (OpenERP)" Date: Mon, 28 Nov 2011 18:17:50 +0530 Subject: [PATCH 10/35] [IMP,ADD,MOVE]stock: Add physical-inventory.yml Improve it. Move stock_report.yml => stock/test/ui/stock_report.yml bzr revid: dbr@tinyerp.com-20111128124750-z3nchmf7w18s2dfh --- addons/stock/__openerp__.py | 3 +- addons/stock/test/ui/physical_inventory.yml | 37 +++++++++++++++++++++ addons/stock/test/{ => ui}/stock_report.yml | 0 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 addons/stock/test/ui/physical_inventory.yml rename addons/stock/test/{ => ui}/stock_report.yml (100%) diff --git a/addons/stock/__openerp__.py b/addons/stock/__openerp__.py index ffe888c1d2b..f568fc90dbf 100644 --- a/addons/stock/__openerp__.py +++ b/addons/stock/__openerp__.py @@ -82,8 +82,9 @@ Thanks to the double entry management, the inventory controlling is powerful and "board_warehouse_view.xml", ], 'test': [ + 'test/ui/physical_inventory.yml', 'test/process/update_stock.yml', - #'test/stock_report.yml', + #'test/ui/stock_report.yml', #'test/stock_test_wizard.yml', 'test/process/stock_demo_backorder.yml', 'test/process/scrap_move.yml', diff --git a/addons/stock/test/ui/physical_inventory.yml b/addons/stock/test/ui/physical_inventory.yml new file mode 100644 index 00000000000..be60fc974b7 --- /dev/null +++ b/addons/stock/test/ui/physical_inventory.yml @@ -0,0 +1,37 @@ +- + I create a record for 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 +- + Now, Define the location for import inventory. +- + !record {model: stock.fill.inventory, id: stock_fill_inventory_0}: + location_id: stock.stock_location_stock + recursive: False + set_stock_zero: False +- + I fill inventory. +- + !python {model: stock.fill.inventory}: | + context = {"full": "1", "active_model": "stock.inventory", "active_ids":[ref("stock_physical_inventory0")], "active_id": ref("stock_physical_inventory0")} + self.view_init(cr, uid, ["set_stock_zero", "location_id", "recursive"], context) + self.fill_inventory(cr, uid, [ref("stock_fill_inventory_0")], context) +- + I confirm the Inventory. +- + !python {model: stock.inventory}: | + inventory = self.browse(cr, uid, [ref('stock_physical_inventory0')]) + self.action_confirm(cr,uid,[ref('stock_physical_inventory0')]) + assert inventory[0].state == 'confirm',"After confirm the inventory it should be in 'Confirm' state" + self.action_done(cr,uid,[ref('stock_physical_inventory0')]) +- + I Validate the Inventory. +- + !python {model: stock.inventory}: | + inventory = self.browse(cr, uid, [ref('stock_physical_inventory0')]) + assert inventory[0].state == 'done',"After validate the inventory it should be in 'Done' state" + diff --git a/addons/stock/test/stock_report.yml b/addons/stock/test/ui/stock_report.yml similarity index 100% rename from addons/stock/test/stock_report.yml rename to addons/stock/test/ui/stock_report.yml From 7e8db1986a91d8a7eaa3242f552ba980f76d0d88 Mon Sep 17 00:00:00 2001 From: "DBR (OpenERP)" Date: Mon, 28 Nov 2011 18:39:22 +0530 Subject: [PATCH 11/35] [IMP]stock: Improve physical inventory test case for set to zero option bzr revid: dbr@tinyerp.com-20111128130922-vunolv3ieg1nasct --- addons/stock/test/ui/physical_inventory.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/stock/test/ui/physical_inventory.yml b/addons/stock/test/ui/physical_inventory.yml index be60fc974b7..f64a0777c4c 100644 --- a/addons/stock/test/ui/physical_inventory.yml +++ b/addons/stock/test/ui/physical_inventory.yml @@ -12,7 +12,7 @@ !record {model: stock.fill.inventory, id: stock_fill_inventory_0}: location_id: stock.stock_location_stock recursive: False - set_stock_zero: False + set_stock_zero: True - I fill inventory. - @@ -27,9 +27,11 @@ inventory = self.browse(cr, uid, [ref('stock_physical_inventory0')]) self.action_confirm(cr,uid,[ref('stock_physical_inventory0')]) assert inventory[0].state == 'confirm',"After confirm the inventory it should be in 'Confirm' state" + for line in inventory[0].inventory_line_id: + assert line.product_qty == 0.0,"Product Quantity should be Zero" self.action_done(cr,uid,[ref('stock_physical_inventory0')]) - - I Validate the Inventory. + I check the Inventory after Validate. - !python {model: stock.inventory}: | inventory = self.browse(cr, uid, [ref('stock_physical_inventory0')]) From 68e863c3fdefb2bdab583f7e0e082e86e88cdeb5 Mon Sep 17 00:00:00 2001 From: "DBR (OpenERP)" Date: Tue, 29 Nov 2011 12:20:12 +0530 Subject: [PATCH 12/35] [IMP]stock: Improve the report yml file bzr revid: dbr@tinyerp.com-20111129065012-xc7ekx1sadvwi2t3 --- addons/stock/__openerp__.py | 2 +- addons/stock/test/ui/physical_inventory.yml | 5 ++++- addons/stock/test/ui/stock_report.yml | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/addons/stock/__openerp__.py b/addons/stock/__openerp__.py index f568fc90dbf..701d0ce482a 100644 --- a/addons/stock/__openerp__.py +++ b/addons/stock/__openerp__.py @@ -84,10 +84,10 @@ Thanks to the double entry management, the inventory controlling is powerful and 'test': [ 'test/ui/physical_inventory.yml', 'test/process/update_stock.yml', - #'test/ui/stock_report.yml', #'test/stock_test_wizard.yml', 'test/process/stock_demo_backorder.yml', 'test/process/scrap_move.yml', + 'test/ui/stock_report.yml', ], 'installable': True, 'active': False, diff --git a/addons/stock/test/ui/physical_inventory.yml b/addons/stock/test/ui/physical_inventory.yml index f64a0777c4c..c061901f88c 100644 --- a/addons/stock/test/ui/physical_inventory.yml +++ b/addons/stock/test/ui/physical_inventory.yml @@ -19,7 +19,10 @@ !python {model: stock.fill.inventory}: | context = {"full": "1", "active_model": "stock.inventory", "active_ids":[ref("stock_physical_inventory0")], "active_id": ref("stock_physical_inventory0")} self.view_init(cr, uid, ["set_stock_zero", "location_id", "recursive"], context) - self.fill_inventory(cr, uid, [ref("stock_fill_inventory_0")], context) + try: + self.fill_inventory(cr, uid, [ref("stock_fill_inventory_0")], context) + except: + pass - I confirm the Inventory. - diff --git a/addons/stock/test/ui/stock_report.yml b/addons/stock/test/ui/stock_report.yml index 41acade696a..0da58de2ad6 100644 --- a/addons/stock/test/ui/stock_report.yml +++ b/addons/stock/test/ui/stock_report.yml @@ -27,7 +27,7 @@ - !python {model: stock.picking}: | import netsvc, tools, os - (data, format) = netsvc.LocalService('report.stock.picking.list').create(cr, uid, [ref('stock.stock_picking_0')], {}, {}) + (data, format) = netsvc.LocalService('report.stock.picking.list').create(cr, uid, [ref('stock.stock_picking_1')], {}, {}) if tools.config['test_report_directory']: file(os.path.join(tools.config['test_report_directory'], 'stock-picking_list'+format), 'wb+').write(data) - From f34bb6b30a4768f522f1feb8e7f23f791fe555a9 Mon Sep 17 00:00:00 2001 From: "DBR (OpenERP)" Date: Tue, 29 Nov 2011 13:08:26 +0530 Subject: [PATCH 13/35] [IMP,MOVE]stock: Move stock_test_wizard.yml => process/stock_chain_location.yml remove chain location code from update_stock.yml and put it in right place update the __openerp__.py bzr revid: dbr@tinyerp.com-20111129073826-x09k58mxyji548yx --- addons/stock/__openerp__.py | 2 +- .../test/process/stock_chain_location.yml | 37 +++++++++ addons/stock/test/process/update_stock.yml | 52 ++----------- addons/stock/test/stock_test_wizard.yml | 78 ------------------- addons/stock/test/ui/physical_inventory.yml | 6 +- 5 files changed, 49 insertions(+), 126 deletions(-) create mode 100644 addons/stock/test/process/stock_chain_location.yml delete mode 100644 addons/stock/test/stock_test_wizard.yml diff --git a/addons/stock/__openerp__.py b/addons/stock/__openerp__.py index 7ef40398683..6bdd77565d2 100644 --- a/addons/stock/__openerp__.py +++ b/addons/stock/__openerp__.py @@ -84,7 +84,7 @@ Thanks to the double entry management, the inventory controlling is powerful and 'test': [ 'test/ui/physical_inventory.yml', 'test/process/update_stock.yml', - #'test/stock_test_wizard.yml', + 'test/process/stock_chain_location.yml', 'test/process/stock_demo_backorder.yml', 'test/process/scrap_move.yml', 'test/ui/stock_report.yml', diff --git a/addons/stock/test/process/stock_chain_location.yml b/addons/stock/test/process/stock_chain_location.yml new file mode 100644 index 00000000000..30e134ccdbe --- /dev/null +++ b/addons/stock/test/process/stock_chain_location.yml @@ -0,0 +1,37 @@ +- + In order to test the chain location functionality, + I create stock production lot for product 'Sprouting Foods'. +- + !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: 0000002 +- + I update product 'Sprouting Foods' with the help of 'Change Product Quantity' wizard + and assign a location 'Refrigerated Vehicles' to test the chained location flow. +- + !python {model: stock.change.product.qty}: | + product = self.pool.get('product.product').browse(cr, uid, ref('product.product_product_sprouting')) + fields = {'location_id' : ref('refrigerate_location_stock'), 'new_quantity': 1, 'product_id': product.id, 'prodlot_id': ref('stock.stock_production_lot2')} + 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]}) +- + I check stock moves of product 'Sprouting Foods'. +- + !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 == 'Refrigerated Vehicles',"Destination location must be 'Refrigerated Vehicles'" + if i.location_id.name == 'Refrigerated Vehicles': + 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'" +- + I trace the stock production lot for product 'Sprouting Foods' +- + !python {model: stock.production.lot }: | + self.action_traceability(cr,uid,[ref('stock_production_lot2')], {'active_model': 'ir.ui.menu', 'field': '', 'type': ''}) + + diff --git a/addons/stock/test/process/update_stock.yml b/addons/stock/test/process/update_stock.yml index 7117fe669e8..e7cd514fe49 100644 --- a/addons/stock/test/process/update_stock.yml +++ b/addons/stock/test/process/update_stock.yml @@ -1,40 +1,39 @@ - - In order to test the stock module, I will update the current stock of the product. + In order to test the stock module, I will update the current stock of the product '[CPU2]High speed processor config'. - I assignd the created location in to warehouse. - !record {model: stock.warehouse, id: stock.warehouse0}: lot_stock_id: stock_location_stock - - I create stock production lot for product CPU2 + I create stock production lot for '[CPU2]High speed processor config' product. - !record {model: stock.production.lot, id: stock_production_lot0}: product_id: product.product_product_cpu2 date: !eval time.strftime('%Y-%m-%d %H:%M:%S') name: 0000001 - - I take one product CPU2 and with the help of 'Change Product Quantity' wizard I update the product stock. - Changes the Product Quantity by making a Physical Inventory. + 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': 2, 'product_id': product.id, 'prodlot_id': ref('stock.stock_production_lot0')} + 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]}) - assert product.qty_available == 2,'Product Quantity is not Updated' + assert product.qty_available == 5,'Product Quantity is not Updated' - - I trace the Stock Production Lot for product CPU2 + I trace the stock production lot for '[CPU2]High speed processor config' product. - !python {model: stock.production.lot }: | self.action_traceability(cr,uid,[ref('stock_production_lot0')], {'lang': 'en_US', 'tz': False, 'active_model': 'ir.ui.menu', 'field': '', 'type': ''}) - - I check Physical Inventory created. + I check physical inventory created. - !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 == 2,'product Quantity 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' - @@ -43,39 +42,4 @@ !python {model: stock.move}: | ids = self.search(cr, uid, [('product_id','=',ref('product.product_product_cpu2'))]) assert [x.state for x in self.browse(cr, uid, ids) if x.state == 'done'], 'stock moves should be done!' -- - For the test chain location functionality, - I create stock production lot for product 'Sprouting Foods'. -- - !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: 0000002 -- - I update product 'Sprouting Foods' with the help of 'Change Product Quantity' wizard - and assign a location 'Refrigerated Vehicles' to test the chained location flow. -- - !python {model: stock.change.product.qty}: | - product = self.pool.get('product.product').browse(cr, uid, ref('product.product_product_sprouting')) - fields = {'location_id' : ref('refrigerate_location_stock'), 'new_quantity': 1, 'product_id': product.id, 'prodlot_id': ref('stock.stock_production_lot2')} - 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]}) -- - I check stock moves of product 'Sprouting Foods'. -- - !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 == 'Refrigerated Vehicles',"Destination location must be 'Refrigerated Vehicles'" - if i.location_id.name == 'Refrigerated Vehicles': - 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'" -- - I trace the stock production lot for product 'Sprouting Foods' -- - !python {model: stock.production.lot }: | - self.action_traceability(cr,uid,[ref('stock_production_lot2')], {'active_model': 'ir.ui.menu', 'field': '', 'type': ''}) diff --git a/addons/stock/test/stock_test_wizard.yml b/addons/stock/test/stock_test_wizard.yml deleted file mode 100644 index 6c4d5ae12c2..00000000000 --- a/addons/stock/test/stock_test_wizard.yml +++ /dev/null @@ -1,78 +0,0 @@ - -- - I create stock.tracking record. -- - !record {model: stock.tracking, id: stock_tracking_0}: - move_ids: - - product_id: product.product_product_pc1 - product_qty: 5.0 - product_uom: product.product_uom_unit - location_id : stock.stock_location_suppliers - location_dest_id: stock.stock_location_shop0 - name : '[PC1] Basic PC' - date_expected : !eval time.strftime('%Y-%m-%d %H:%M:%S') - name: 0000007 - active: True - date: !eval time.strftime('%Y-%m-%d %H:%M:%S') - -- - I trace the information of a product. -- - !python {model: stock.tracking}: | - self.name_get(cr, uid, [ref('stock_tracking_0')],{'lang': 'en_US', 'tz': False, 'active_model': 'ir.ui.menu', 'field': '', 'type': ''}) - self.action_traceability(cr,uid,[ref('stock_tracking_0')], {'lang': 'en_US', 'tz': False, 'active_model': 'ir.ui.menu', 'field': '', 'type': ''}) - -- - I creat stock.move Record -- - !record {model: stock.move, id: stock_move_test0}: - location_dest_id: stock.stock_location_shop0 - product_id: product.product_product_pc1 - product_qty: 5.0 - product_uom: product.product_uom_unit - date_expected : !eval time.strftime('%Y-%m-%d %H:%M:%S') - location_id : stock.stock_location_suppliers - name : '[PC1] Basic PC' - company_id: base.main_company - product_uos_qty : 5.0 - name: IN/00010 - state: assigned - -- - I Check onchange function of stock.move object -- - !python {model: stock.move }: | - self.onchange_lot_id(cr, uid, [ref("stock_move_test0")], ref("stock.stock_production_lot0"), 5, ref("stock.stock_location_suppliers"), ref("product.product_product_pc1"), ref("product.product_uom_unit"), None) - self.onchange_quantity(cr, uid, [ref("stock_move_test0")], ref("product.product_product_pc1"), 10, ref("product.product_uom_unit"), ref("product.product_uom_unit")) - self.onchange_uos_quantity(cr, uid, [ref("stock_move_test0")], ref("product.product_product_pc1"), 10, ref("product.product_uom_unit"), ref("product.product_uom_unit")) - self.onchange_product_id(cr, uid, [ref("stock_move_test0")], ref("product.product_product_pc1"), ref("stock.stock_location_suppliers"), ref("stock.stock_location_shop0"), False) - -- - I Check _getSSCC and action_partial_move function of stock.move object -- - !python {model: stock.move }: | - context = {"lang": 'en_US', "default_location_dest_id": ref("stock.stock_location_shop0"), "active_model": - "stock.move", "search_default_receive": 1, 'product_receive': True, "default_location_id": ref("stock.stock_location_suppliers"),"active_ids":[ref("stock_move_test0")], "tz": False, "active_id":ref("stock_move_test0")} - self._getSSCC(cr, uid , context) - self.action_partial_move(cr, uid , [ref("stock_move_test0")], context) - -- - I check write function -- - !python {model: stock.move }: | - vals = {"product_qty" : 2, "product_uos_qty": 2} - self.write(cr, uid, [ref("stock_move_test0")], vals, {"lang": 'en_US', "default_location_dest_id": ref("stock.stock_location_shop0"), "active_model": - "ir.ui.menu", "search_default_receive": 1, 'product_receive': True, "default_location_id": ref("stock.stock_location_suppliers"),"active_ids":[ref("stock_move_tree")], "tz": False, "active_id":ref("stock_move_tree")}) - -- - I check default function -- - !python {model: stock.move }: | - self.name_get(cr, uid, [ref("stock_move_test0")], {"lang": 'en_US', "default_location_dest_id": ref("stock.stock_location_shop0"), "active_model": - "stock.move", "search_default_receive": 1, 'product_receive': True, "default_location_id": ref("stock.stock_location_suppliers"),"active_ids":[ref("stock_move_test0")], "tz": False, "active_id":ref("stock_move_test0")}) - ctx = {"lang": 'en_US', "default_location_dest_id": ref("stock.stock_location_shop0"), "active_model": - "ir.ui.menu", "search_default_receive": 1, 'product_receive': True, "default_location_id": ref("stock.stock_location_suppliers"),"active_ids":[ref("view_move_form_reception_picking")], "tz": False, "active_id":ref("view_move_form_reception_picking")} - self._default_location_destination(cr, uid, ctx) - self._default_location_source(cr, uid, ctx) - - diff --git a/addons/stock/test/ui/physical_inventory.yml b/addons/stock/test/ui/physical_inventory.yml index c061901f88c..3282694c4ac 100644 --- a/addons/stock/test/ui/physical_inventory.yml +++ b/addons/stock/test/ui/physical_inventory.yml @@ -1,5 +1,5 @@ - - I create a record for physical inventory. + I create a record for 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 @@ -24,7 +24,7 @@ except: pass - - I confirm the Inventory. + I confirm the inventory. - !python {model: stock.inventory}: | inventory = self.browse(cr, uid, [ref('stock_physical_inventory0')]) @@ -34,7 +34,7 @@ assert line.product_qty == 0.0,"Product Quantity should be Zero" self.action_done(cr,uid,[ref('stock_physical_inventory0')]) - - I check the Inventory after Validate. + I check the inventory after validation. - !python {model: stock.inventory}: | inventory = self.browse(cr, uid, [ref('stock_physical_inventory0')]) From 8d24067e75f3cbe94a38e86accdbc4b8474d1bc5 Mon Sep 17 00:00:00 2001 From: "DBR (OpenERP)" Date: Tue, 29 Nov 2011 16:38:32 +0530 Subject: [PATCH 14/35] [ADD,IMP]stock: Add new file for define test case of new picking functionality Add one more move in demo picking for new picking Update __openerp__.py bzr revid: dbr@tinyerp.com-20111129110832-eu8zx0fnfct5ktjn --- addons/stock/__openerp__.py | 1 + addons/stock/stock_demo_picking.yml | 12 +++++++++ .../test/process/stock_demo_backorder.yml | 4 +-- addons/stock/test/process/stock_new_pack.yml | 25 +++++++++++++++++++ 4 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 addons/stock/test/process/stock_new_pack.yml diff --git a/addons/stock/__openerp__.py b/addons/stock/__openerp__.py index 6bdd77565d2..b7538832bb7 100644 --- a/addons/stock/__openerp__.py +++ b/addons/stock/__openerp__.py @@ -87,6 +87,7 @@ Thanks to the double entry management, the inventory controlling is powerful and 'test/process/stock_chain_location.yml', 'test/process/stock_demo_backorder.yml', 'test/process/scrap_move.yml', + 'test/process/stock_new_pack.yml', 'test/ui/stock_report.yml', ], 'installable': True, diff --git a/addons/stock/stock_demo_picking.yml b/addons/stock/stock_demo_picking.yml index 62732c82cdb..66579e49ab7 100644 --- a/addons/stock/stock_demo_picking.yml +++ b/addons/stock/stock_demo_picking.yml @@ -29,3 +29,15 @@ location_id: stock.stock_location_stock name: CPU3, Processor AMD Athlon XP 1800 picking_id: stock_picking_1 +- + Created one more Move +- + !record {model: stock.move, id: stock_move_3}: + product_id: product.product_product_pc1 + product_uom: product.product_uom_unit + product_uos_qty: 5.0 + product_qty: 5.0 + location_dest_id: stock.stock_location_customers + location_id: stock.stock_location_stock + name: PC1, Basic PC + picking_id: stock_picking_1 diff --git a/addons/stock/test/process/stock_demo_backorder.yml b/addons/stock/test/process/stock_demo_backorder.yml index 3da67e369f2..5df0f922c59 100644 --- a/addons/stock/test/process/stock_demo_backorder.yml +++ b/addons/stock/test/process/stock_demo_backorder.yml @@ -54,9 +54,9 @@ pick = self.browse(cr, uid, ref('stock.stock_picking_1'), {}) for line in pick.move_lines: if line.product_id.id == ref('product.product_product_cpu3'): - assert line.product_qty == 5.0, "Wrong quantity %.2f for CPU3 back order" % (line.product_qty,) + assert line.product_qty == 5.0, "Wrong quantity %s for CPU3 back order" % (line.product_qty,) elif line.product_id.id == ref('product.product_product_fan2'): - assert line.product_qty == 4.0, "Wrong quantity %.2f for FAN2 back order" % (line.product_qty,) + assert line.product_qty == 4.0, "Wrong quantity %s for FAN2 back order" % (line.product_qty,) elif line.product_id.id == ref('product.product_product_pc1'): assert line.product_qty == 0.0, "Wrong quantity for PC1 back order" else: diff --git a/addons/stock/test/process/stock_new_pack.yml b/addons/stock/test/process/stock_new_pack.yml new file mode 100644 index 00000000000..e5f584a47c0 --- /dev/null +++ b/addons/stock/test/process/stock_new_pack.yml @@ -0,0 +1,25 @@ +- + In order to test the new packing facility in OpenERP, I create one pack record. +- + !record {model: stock.tracking, id: stock_tracking_0}: + 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. +- + !record {model: stock.move, id: stock_move_3}: + tracking_id: stock_tracking_0 +- + I split the picking in two quantities. +- + !python {model: stock.move }: | + move_ids=self.browse(cr,uid,ref('stock_move_3')) + old_moves = self.search(cr, uid, [('picking_id','=',move_ids.picking_id.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],{"active_model": "stock.move", "active_ids": [ref('stock_move_3')],"active_id": ref('stock_move_2')}) + moves = self.search(cr, uid, [('picking_id','=',move_ids.picking_id.id)]) + assert len(moves) > len(old_moves),"After spliting the picking, new move should be created" + new_move = self.browse(cr, uid, moves[-1]) + assert new_move.tracking_id,"After spliting the picking, new move should be created with new pack" + From 311f4562051bd4b5968abcb9d4d0a1085ce07256 Mon Sep 17 00:00:00 2001 From: "DBR (OpenERP)" Date: Wed, 30 Nov 2011 14:17:32 +0530 Subject: [PATCH 15/35] [ADD,IMP,MOVE,REMOVE]stock: added: stock/test/cancel_stock.yml stock/test/delete_stock.yml moved: stock/test/process/scrap_move.yml => stock/test/stock_scrap_move.yml stock/test/process/stock_chain_location.yml => stock/test/stock_chain_location.yml stock/test/process/stock_demo_backorder.yml => stock/test/stock_demo_backorder.yml stock/test/process/stock_new_pack.yml => stock/test/stock_new_pack.yml stock/test/process/update_stock.yml => stock/test/stock_update.yml stock/test/ui/physical_inventory.yml => stock/test/stock_physical_inventory.yml stock/test/ui/stock_report.yml => stock/test/stock_report.yml removed: stock/test/process/ stock/test/ui/ improve: stock/__openerp__.py bzr revid: dbr@tinyerp.com-20111130084732-lt26y2ypgnb3k476 --- addons/stock/__openerp__.py | 16 ++++--- addons/stock/test/cancel_stock.yml | 47 +++++++++++++++++++ addons/stock/test/delete_stock.yml | 26 ++++++++++ .../{process => }/stock_chain_location.yml | 0 .../{process => }/stock_demo_backorder.yml | 0 .../test/{process => }/stock_new_pack.yml | 0 ...ntory.yml => stock_physical_inventory.yml} | 0 addons/stock/test/{ui => }/stock_report.yml | 0 .../scrap_move.yml => stock_scrap_move.yml} | 0 .../update_stock.yml => stock_update.yml} | 0 10 files changed, 82 insertions(+), 7 deletions(-) create mode 100644 addons/stock/test/cancel_stock.yml create mode 100644 addons/stock/test/delete_stock.yml rename addons/stock/test/{process => }/stock_chain_location.yml (100%) rename addons/stock/test/{process => }/stock_demo_backorder.yml (100%) rename addons/stock/test/{process => }/stock_new_pack.yml (100%) rename addons/stock/test/{ui/physical_inventory.yml => stock_physical_inventory.yml} (100%) rename addons/stock/test/{ui => }/stock_report.yml (100%) rename addons/stock/test/{process/scrap_move.yml => stock_scrap_move.yml} (100%) rename addons/stock/test/{process/update_stock.yml => stock_update.yml} (100%) diff --git a/addons/stock/__openerp__.py b/addons/stock/__openerp__.py index b7538832bb7..5faf67b5e48 100644 --- a/addons/stock/__openerp__.py +++ b/addons/stock/__openerp__.py @@ -82,13 +82,15 @@ Thanks to the double entry management, the inventory controlling is powerful and "board_warehouse_view.xml", ], 'test': [ - 'test/ui/physical_inventory.yml', - 'test/process/update_stock.yml', - 'test/process/stock_chain_location.yml', - 'test/process/stock_demo_backorder.yml', - 'test/process/scrap_move.yml', - 'test/process/stock_new_pack.yml', - 'test/ui/stock_report.yml', + 'test/stock_physical_inventory.yml', + '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_report.yml', + 'test/delete_stock.yml', + 'test/cancel_stock.yml', ], 'installable': True, 'active': False, diff --git a/addons/stock/test/cancel_stock.yml b/addons/stock/test/cancel_stock.yml new file mode 100644 index 00000000000..d3ba057a755 --- /dev/null +++ b/addons/stock/test/cancel_stock.yml @@ -0,0 +1,47 @@ +- + In order to test the cancel stock. I start from cancelling the incoming shipment. +- + First, I create copies of incoming shipment. +- + !python {model: stock.picking}: | + stock = self.pool.get('stock.move') + context.update({'active_id':ref('stock.stock_picking_1')}) + id1 = self.copy(cr, uid, ref('stock.stock_picking_1'), context) + id2 = self.copy(cr, uid, ref('stock.stock_picking_1'), context) + id3 = self.copy(cr, uid, ref('stock.stock_picking_1'), context) + context.update({'id1':id1,'id2':id2,'id3':id3}) +- + Now, I cancel all related moves of picking so automatically picking goes to cancelled state.. +- + !python {model: stock.picking}: | + import netsvc + wf_service = netsvc.LocalService("workflow") + stock = self.pool.get('stock.move') + pick = self.browse(cr, uid, context.get('id1')) + move_ids = stock.search(cr, uid, [('picking_id','=',pick.name)]) + for move in move_ids: + wf_service.trg_validate(uid, 'stock.move', move, 'action_confirm', cr) + stock.force_assign(cr, uid, move) + wf_service.trg_validate(uid, 'stock.move', move, 'action_cancel', cr) +- + Now, directlly cancel the picking. +- + !python {model: stock.picking}: | + import netsvc + wf_service = netsvc.LocalService("workflow") + pick_id = context.get('id2') + wf_service.trg_validate(uid, 'stock.picking', pick_id, 'button_cancel', cr) +- + I return the picking. +- + !python {model: stock.picking}: | + copy_id = context.get('id3') + self.draft_force_assign(cr, uid, [copy_id]) + self.force_assign(cr, uid, [copy_id]) + stock_partial_picking = self.pool.get('stock.partial.picking') + context.update({'active_model': 'stock.picking','active_ids': [copy_id],'active_id': copy_id}) + partial_id = stock_partial_picking.create(cr, uid, {}, context=context) + stock_partial_picking.do_partial(cr, uid, [partial_id], context) + return_pick_id = self.pool.get('stock.return.picking').create(cr, uid,{}, context) + self.pool.get('stock.return.picking').create_returns(cr, uid, [return_pick_id], context) + diff --git a/addons/stock/test/delete_stock.yml b/addons/stock/test/delete_stock.yml new file mode 100644 index 00000000000..c81258511c4 --- /dev/null +++ b/addons/stock/test/delete_stock.yml @@ -0,0 +1,26 @@ +- + In order to test the delete stock, create a copy of picking. +- + First, I create copy of picking. +- + !python {model: stock.picking}: | + context.update({'active_id':ref('stock.stock_picking_1')}) + pick = self.browse(cr, uid, ref('stock.stock_picking_1')) + stock = self.pool.get('stock.move') + move_ids = stock.search(cr, uid, [('picking_id','=',pick.name)]) + id1 = self.copy(cr, uid, ref('stock.stock_picking_1'), context) + move_id = stock.copy(cr, uid, move_ids[0],context) + context.update({'id1':id1,'move':move_id}) +- + Now, I delete a related moves of picking. +- + !python {model: stock.move}: | + move = context.get('move') + self.unlink(cr, uid, [move]) +- + Now, directlly delete the picking. +- + !python {model: stock.picking}: | + id = context.get('id1') + self.unlink(cr, uid, [id]) + diff --git a/addons/stock/test/process/stock_chain_location.yml b/addons/stock/test/stock_chain_location.yml similarity index 100% rename from addons/stock/test/process/stock_chain_location.yml rename to addons/stock/test/stock_chain_location.yml diff --git a/addons/stock/test/process/stock_demo_backorder.yml b/addons/stock/test/stock_demo_backorder.yml similarity index 100% rename from addons/stock/test/process/stock_demo_backorder.yml rename to addons/stock/test/stock_demo_backorder.yml diff --git a/addons/stock/test/process/stock_new_pack.yml b/addons/stock/test/stock_new_pack.yml similarity index 100% rename from addons/stock/test/process/stock_new_pack.yml rename to addons/stock/test/stock_new_pack.yml diff --git a/addons/stock/test/ui/physical_inventory.yml b/addons/stock/test/stock_physical_inventory.yml similarity index 100% rename from addons/stock/test/ui/physical_inventory.yml rename to addons/stock/test/stock_physical_inventory.yml diff --git a/addons/stock/test/ui/stock_report.yml b/addons/stock/test/stock_report.yml similarity index 100% rename from addons/stock/test/ui/stock_report.yml rename to addons/stock/test/stock_report.yml diff --git a/addons/stock/test/process/scrap_move.yml b/addons/stock/test/stock_scrap_move.yml similarity index 100% rename from addons/stock/test/process/scrap_move.yml rename to addons/stock/test/stock_scrap_move.yml diff --git a/addons/stock/test/process/update_stock.yml b/addons/stock/test/stock_update.yml similarity index 100% rename from addons/stock/test/process/update_stock.yml rename to addons/stock/test/stock_update.yml From cc52af38ea565052fc022a3f686ab6037d10296e Mon Sep 17 00:00:00 2001 From: "DBR (OpenERP)" Date: Wed, 30 Nov 2011 16:18:37 +0530 Subject: [PATCH 16/35] [IMP]stock: Remove extra spaces bzr revid: dbr@tinyerp.com-20111130104837-r8s0cffdm0vpiupg --- addons/stock/stock_demo_picking.yml | 8 ++++---- addons/stock/test/cancel_stock.yml | 1 - addons/stock/test/delete_stock.yml | 1 - addons/stock/test/stock_chain_location.yml | 1 - addons/stock/test/stock_demo_backorder.yml | 1 - addons/stock/test/stock_new_pack.yml | 5 ++--- addons/stock/test/stock_physical_inventory.yml | 5 ++--- addons/stock/test/stock_update.yml | 3 +-- 8 files changed, 9 insertions(+), 16 deletions(-) diff --git a/addons/stock/stock_demo_picking.yml b/addons/stock/stock_demo_picking.yml index 66579e49ab7..d6e5664725a 100644 --- a/addons/stock/stock_demo_picking.yml +++ b/addons/stock/stock_demo_picking.yml @@ -1,12 +1,12 @@ - - Created a picking + Create a picking - !record {model: stock.picking, id: stock_picking_1}: type: out company_id: base.main_company address_id: res_partner_address_fabien0 - - Created a Move + Create a move - !record {model: stock.move, id: stock_move_1}: product_id: product.product_product_cpu1 @@ -18,7 +18,7 @@ name: CPU1, Processor AMD Athlon XP 1800 picking_id: stock_picking_1 - - Created another Move + Create another move - !record {model: stock.move, id: stock_move_2}: product_id: product.product_product_cpu3 @@ -30,7 +30,7 @@ name: CPU3, Processor AMD Athlon XP 1800 picking_id: stock_picking_1 - - Created one more Move + Create one more move - !record {model: stock.move, id: stock_move_3}: product_id: product.product_product_pc1 diff --git a/addons/stock/test/cancel_stock.yml b/addons/stock/test/cancel_stock.yml index d3ba057a755..0159a5ce444 100644 --- a/addons/stock/test/cancel_stock.yml +++ b/addons/stock/test/cancel_stock.yml @@ -44,4 +44,3 @@ stock_partial_picking.do_partial(cr, uid, [partial_id], context) return_pick_id = self.pool.get('stock.return.picking').create(cr, uid,{}, context) self.pool.get('stock.return.picking').create_returns(cr, uid, [return_pick_id], context) - diff --git a/addons/stock/test/delete_stock.yml b/addons/stock/test/delete_stock.yml index c81258511c4..fee3e751a9e 100644 --- a/addons/stock/test/delete_stock.yml +++ b/addons/stock/test/delete_stock.yml @@ -23,4 +23,3 @@ !python {model: stock.picking}: | id = context.get('id1') self.unlink(cr, uid, [id]) - diff --git a/addons/stock/test/stock_chain_location.yml b/addons/stock/test/stock_chain_location.yml index 30e134ccdbe..9b05684bb11 100644 --- a/addons/stock/test/stock_chain_location.yml +++ b/addons/stock/test/stock_chain_location.yml @@ -34,4 +34,3 @@ !python {model: stock.production.lot }: | self.action_traceability(cr,uid,[ref('stock_production_lot2')], {'active_model': 'ir.ui.menu', 'field': '', 'type': ''}) - diff --git a/addons/stock/test/stock_demo_backorder.yml b/addons/stock/test/stock_demo_backorder.yml index 5df0f922c59..e610874850d 100644 --- a/addons/stock/test/stock_demo_backorder.yml +++ b/addons/stock/test/stock_demo_backorder.yml @@ -76,4 +76,3 @@ assert move.state == 'done',"Stock move of %s picking should be in 'Done' state"%(move.picking_id) 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) - diff --git a/addons/stock/test/stock_new_pack.yml b/addons/stock/test/stock_new_pack.yml index e5f584a47c0..245c06e7b51 100644 --- a/addons/stock/test/stock_new_pack.yml +++ b/addons/stock/test/stock_new_pack.yml @@ -3,11 +3,11 @@ - !record {model: stock.tracking, id: stock_tracking_0}: name: 0000007 - date: !eval time.strftime('%Y-%m-%d %H:%M:%S') + date: !eval time.strftime('%Y-%m-%d %H:%M:%S') - I have to take one delivery order move and set the craeted pack. - - !record {model: stock.move, id: stock_move_3}: + !record {model: stock.move, id: stock_move_3}: tracking_id: stock_tracking_0 - I split the picking in two quantities. @@ -22,4 +22,3 @@ assert len(moves) > len(old_moves),"After spliting the picking, new move should be created" new_move = self.browse(cr, uid, moves[-1]) assert new_move.tracking_id,"After spliting the picking, new move should be created with new pack" - diff --git a/addons/stock/test/stock_physical_inventory.yml b/addons/stock/test/stock_physical_inventory.yml index 3282694c4ac..f4ddd012d5c 100644 --- a/addons/stock/test/stock_physical_inventory.yml +++ b/addons/stock/test/stock_physical_inventory.yml @@ -5,7 +5,7 @@ company_id: base.main_company date: !eval time.strftime('%Y-%m-%d %H:%M:%S') name: Physical inventory - state: draft + state: draft - Now, Define the location for import inventory. - @@ -38,5 +38,4 @@ - !python {model: stock.inventory}: | inventory = self.browse(cr, uid, [ref('stock_physical_inventory0')]) - assert inventory[0].state == 'done',"After validate the inventory it should be in 'Done' state" - + assert inventory[0].state == 'done',"After validate the inventory it should be in 'Done' state" diff --git a/addons/stock/test/stock_update.yml b/addons/stock/test/stock_update.yml index e7cd514fe49..19f88dc9f9d 100644 --- a/addons/stock/test/stock_update.yml +++ b/addons/stock/test/stock_update.yml @@ -1,5 +1,5 @@ - - In order to test the stock module, I will update the current stock of the product '[CPU2]High speed processor config'. + In order to test the stock module, I update the current stock of the product '[CPU2]High speed processor config'. - I assignd the created location in to warehouse. - @@ -42,4 +42,3 @@ !python {model: stock.move}: | ids = self.search(cr, uid, [('product_id','=',ref('product.product_product_cpu2'))]) assert [x.state for x in self.browse(cr, uid, ids) if x.state == 'done'], 'stock moves should be done!' - From 57afcbbfd90c711a57ebd07266eccb8886c0d19d Mon Sep 17 00:00:00 2001 From: "DBR (OpenERP)" Date: Wed, 30 Nov 2011 16:40:50 +0530 Subject: [PATCH 17/35] [IMP]stock: Improve the test statements bzr revid: dbr@tinyerp.com-20111130111050-1ib1ea4wv53f3j9p --- addons/stock/test/stock_chain_location.yml | 2 +- addons/stock/test/stock_demo_backorder.yml | 1 + addons/stock/test/stock_new_pack.yml | 4 ++-- addons/stock/test/stock_physical_inventory.yml | 2 ++ addons/stock/test/stock_update.yml | 6 +++--- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/addons/stock/test/stock_chain_location.yml b/addons/stock/test/stock_chain_location.yml index 9b05684bb11..927fa2ec39f 100644 --- a/addons/stock/test/stock_chain_location.yml +++ b/addons/stock/test/stock_chain_location.yml @@ -29,7 +29,7 @@ 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'" - - I trace the stock production lot for product 'Sprouting Foods' + I trace the stock production lot for product 'Sprouting Foods'. - !python {model: stock.production.lot }: | self.action_traceability(cr,uid,[ref('stock_production_lot2')], {'active_model': 'ir.ui.menu', 'field': '', 'type': ''}) diff --git a/addons/stock/test/stock_demo_backorder.yml b/addons/stock/test/stock_demo_backorder.yml index e610874850d..5df0f922c59 100644 --- a/addons/stock/test/stock_demo_backorder.yml +++ b/addons/stock/test/stock_demo_backorder.yml @@ -76,3 +76,4 @@ assert move.state == 'done',"Stock move of %s picking should be in 'Done' state"%(move.picking_id) 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) + diff --git a/addons/stock/test/stock_new_pack.yml b/addons/stock/test/stock_new_pack.yml index 245c06e7b51..fd91238859b 100644 --- a/addons/stock/test/stock_new_pack.yml +++ b/addons/stock/test/stock_new_pack.yml @@ -1,5 +1,5 @@ - - In order to test the new packing facility in OpenERP, I create one pack record. + In order to test the new packing from the existing one, First I create a pack. - !record {model: stock.tracking, id: stock_tracking_0}: name: 0000007 @@ -10,7 +10,7 @@ !record {model: stock.move, id: stock_move_3}: tracking_id: stock_tracking_0 - - I split the picking in two quantities. + I split the picking in to two quantities. - !python {model: stock.move }: | move_ids=self.browse(cr,uid,ref('stock_move_3')) diff --git a/addons/stock/test/stock_physical_inventory.yml b/addons/stock/test/stock_physical_inventory.yml index f4ddd012d5c..30e91c76522 100644 --- a/addons/stock/test/stock_physical_inventory.yml +++ b/addons/stock/test/stock_physical_inventory.yml @@ -1,3 +1,5 @@ +- + In order to test the stock module, I start it from physical inventory. - I create a record for physical inventory and change the product quantity zero by making a physical inventory. - diff --git a/addons/stock/test/stock_update.yml b/addons/stock/test/stock_update.yml index 19f88dc9f9d..70301d41f8a 100644 --- a/addons/stock/test/stock_update.yml +++ b/addons/stock/test/stock_update.yml @@ -1,5 +1,5 @@ - - In order to test the stock module, I update the current stock of the product '[CPU2]High speed processor config'. + I update the current stock of the product '[CPU2]High speed processor config'. - I assignd the created location in to warehouse. - @@ -27,7 +27,7 @@ !python {model: stock.production.lot }: | self.action_traceability(cr,uid,[ref('stock_production_lot0')], {'lang': 'en_US', 'tz': False, 'active_model': 'ir.ui.menu', 'field': '', 'type': ''}) - - I check physical inventory created. + I check that physical inventory created. - !python {model: stock.inventory.line}: | ids = self.search(cr, uid, [('product_id','=',ref('product.product_product_cpu2'))]) @@ -37,7 +37,7 @@ assert inventory.location_id.id == ref('stock_location_stock'), 'Location is not correspond' assert inventory.state == 'done', 'State should be in Done state' - - I check stock moves created. + I check that stock moves created. - !python {model: stock.move}: | ids = self.search(cr, uid, [('product_id','=',ref('product.product_product_cpu2'))]) From fee67a8abab65c39990602b7af731144dd229d01 Mon Sep 17 00:00:00 2001 From: "DBR (OpenERP)" Date: Wed, 7 Dec 2011 15:10:16 +0530 Subject: [PATCH 18/35] [IMP]stock: Improve the YML test cases bzr revid: dbr@tinyerp.com-20111207094016-je57fcseuplkqs54 --- addons/stock/stock_data.xml | 18 +------- addons/stock/stock_demo.xml | 10 ++++- addons/stock/stock_demo_picking.yml | 8 ---- addons/stock/test/cancel_stock.yml | 10 ++--- addons/stock/test/delete_stock.yml | 8 ++-- addons/stock/test/stock_chain_location.yml | 12 +++--- addons/stock/test/stock_demo_backorder.yml | 15 +++---- addons/stock/test/stock_new_pack.yml | 2 +- .../stock/test/stock_physical_inventory.yml | 43 ++++++++++--------- addons/stock/test/stock_report.yml | 2 +- addons/stock/test/stock_scrap_move.yml | 4 +- 11 files changed, 58 insertions(+), 74 deletions(-) diff --git a/addons/stock/stock_data.xml b/addons/stock/stock_data.xml index 3f8fd8113ce..941173f348d 100644 --- a/addons/stock/stock_data.xml +++ b/addons/stock/stock_data.xml @@ -90,14 +90,7 @@ view - - Cold Storage - - fixed - - auto - internal - + Delivery Orders @@ -112,15 +105,6 @@ - - Refrigerated Vehicles - - auto - fixed - internal - - - Stock diff --git a/addons/stock/stock_demo.xml b/addons/stock/stock_demo.xml index 8cacdba9919..ef85f5a494b 100644 --- a/addons/stock/stock_demo.xml +++ b/addons/stock/stock_demo.xml @@ -9,7 +9,7 @@ - + Cold Storage fixed @@ -50,6 +50,14 @@ Shelf 1 + + Refrigerated Vehicles + + auto + fixed + internal + +