From 2b3fb50997b720344788672313464b2e64e2a62b Mon Sep 17 00:00:00 2001 From: Josse Colpaert Date: Thu, 18 Jul 2013 18:47:15 +0200 Subject: [PATCH] [WIP] Add YML files and check stock/shipment.yml, make sure stock_account takes all the files(__openerp__.py) and that way start handling problems purchase fifo lifo tests bzr revid: jco@openerp.com-20130718164715-m2c7mbkb5ph9a82g --- addons/purchase/test/average_price.yml | 5 - addons/purchase/test/fifo_price.yml | 17 -- addons/purchase/test/fifo_returns.yml | 1 - addons/purchase/test/lifo_price.yml | 6 - addons/stock/__openerp__.py | 4 +- addons/stock/stock_demo.yml | 2 - addons/stock/test/move.yml | 2 +- addons/stock/test/packing.yml | 22 +++ addons/stock/test/procrule.yml | 4 + addons/stock/test/shipment.yml | 161 +----------------- addons/stock_account/__openerp__.py | 40 +---- addons/stock_account/product_data.xml | 2 +- addons/stock_account/stock_account_view.xml | 28 +-- addons/stock_complex_routes/test/dropship.yml | 21 +++ 14 files changed, 67 insertions(+), 248 deletions(-) create mode 100644 addons/stock/test/packing.yml create mode 100644 addons/stock/test/procrule.yml create mode 100644 addons/stock_complex_routes/test/dropship.yml diff --git a/addons/purchase/test/average_price.yml b/addons/purchase/test/average_price.yml index 98e7c74e01a..0fa2dfb0a4f 100644 --- a/addons/purchase/test/average_price.yml +++ b/addons/purchase/test/average_price.yml @@ -8,7 +8,6 @@ categ_id: product.product_category_1 uom_id: product.product_uom_kgm uom_po_id: product.product_uom_kgm - procure_method: make_to_stock valuation: real_time cost_method: average property_stock_account_input: account.o_expense @@ -98,10 +97,6 @@ - !python {model: stock.picking}: | self.action_assign(cr, uid, [ref("outgoing_average_shipment")]) -- - I confirm outgoing shipment of 20 kg of Average Ice Cream. -- - !workflow {model: stock.picking, action: button_confirm, ref: outgoing_average_shipment} - Process the delivery of the outgoing shipment - diff --git a/addons/purchase/test/fifo_price.yml b/addons/purchase/test/fifo_price.yml index 6bf072c4b02..e6488bcc141 100644 --- a/addons/purchase/test/fifo_price.yml +++ b/addons/purchase/test/fifo_price.yml @@ -10,7 +10,6 @@ standard_price: 70.0 uom_id: product.product_uom_kgm uom_po_id: product.product_uom_kgm - procure_method: make_to_stock cost_method: real valuation: real_time property_stock_account_input: account.o_expense @@ -107,10 +106,6 @@ product_uom: product.product_uom_kgm product_qty: 20.0 type: out -- - I confirm outgoing shipment of 20 kg of FIFO Ice Cream. -- - !workflow {model: stock.picking, action: button_confirm, ref: outgoing_fifo_shipment} - I assign this outgoing shipment - @@ -141,10 +136,6 @@ product_uom: product.product_uom_gram product_qty: 500.0 type: out -- - I confirm outgoing shipment of 500g of FIFO Ice Cream. -- - !workflow {model: stock.picking, action: button_confirm, ref: outgoing_fifo_shipment_uom} - I assign this outgoing shipment - @@ -228,10 +219,6 @@ product_uom: product.product_uom_kgm product_qty: 49.5 type: out -- - I confirm outgoing shipment of 49.5 kg -- - !workflow {model: stock.picking, action: button_confirm, ref: outgoing_fifo_shipment_cur} - I assign this outgoing shipment - @@ -262,10 +249,6 @@ product_uom: product.product_uom_kgm product_qty: 10.0 type: out -- - I confirm outgoing shipment of 10 kg of FIFO Ice Cream. -- - !workflow {model: stock.picking, action: button_confirm, ref: outgoing_fifo_shipment_ret} - I assign this outgoing shipment - diff --git a/addons/purchase/test/fifo_returns.yml b/addons/purchase/test/fifo_returns.yml index a0fadeb5604..19fa9a6df38 100644 --- a/addons/purchase/test/fifo_returns.yml +++ b/addons/purchase/test/fifo_returns.yml @@ -8,7 +8,6 @@ categ_id: product.product_category_1 uom_id: product.product_uom_kgm uom_po_id: product.product_uom_kgm - procure_method: make_to_stock cost_method: real valuation: real_time property_stock_account_input: account.o_expense diff --git a/addons/purchase/test/lifo_price.yml b/addons/purchase/test/lifo_price.yml index 2e51a8cbca9..ea30317b996 100644 --- a/addons/purchase/test/lifo_price.yml +++ b/addons/purchase/test/lifo_price.yml @@ -15,7 +15,6 @@ standard_price: 70.0 uom_id: product.product_uom_kgm uom_po_id: product.product_uom_kgm - procure_method: make_to_stock valuation: real_time cost_method: real property_stock_account_input: account.o_expense @@ -98,11 +97,6 @@ product_uom: product.product_uom_kgm product_qty: 20.0 type: out - -- - I confirm outgoing shipment of 20 kg of LIFO Ice Cream. -- - !workflow {model: stock.picking, action: button_confirm, ref: outgoing_lifo_shipment} - I assign this outgoing shipment - diff --git a/addons/stock/__openerp__.py b/addons/stock/__openerp__.py index 1491ee237ce..af6ce4f6b21 100644 --- a/addons/stock/__openerp__.py +++ b/addons/stock/__openerp__.py @@ -61,7 +61,7 @@ Dashboard / Reports for Warehouse Management will include: 'stock_demo.xml', 'procurement_demo.xml', 'stock_orderpoint.xml', -# 'stock_demo.yml', + 'stock_demo.yml', ], 'data': [ 'security/stock_security.xml', @@ -95,7 +95,7 @@ Dashboard / Reports for Warehouse Management will include: 'test': [ 'test/inventory.yml', 'test/move.yml', -# 'test/shipment.yml', + 'test/shipment.yml', ], 'installable': True, 'application': True, diff --git a/addons/stock/stock_demo.yml b/addons/stock/stock_demo.yml index 8289898ccf3..a3a712cc5d7 100644 --- a/addons/stock/stock_demo.yml +++ b/addons/stock/stock_demo.yml @@ -38,7 +38,6 @@ property_stock_inventory: location_opening valuation: real_time description: Ice cream can be mass-produced and thus is widely available in developed parts of the world. Ice cream can be purchased in large cartons (vats and squrounds) from supermarkets and grocery stores, in smaller quantities from ice cream shops, convenience stores, and milk bars, and in individual servings from small carts or vans at public events. - - !record {model: stock.production.lot, id: lot_icecream_0}: name: Lot0 for Ice cream @@ -66,7 +65,6 @@ product_qty: 40.0 prod_lot_id: lot_icecream_1 location_id: location_refrigerator - - !record {model: stock.picking, id: outgoing_shipment}: type: out diff --git a/addons/stock/test/move.yml b/addons/stock/test/move.yml index bc1710adaf3..696ef6f8976 100644 --- a/addons/stock/test/move.yml +++ b/addons/stock/test/move.yml @@ -16,7 +16,7 @@ !python {model: stock.move}: | self.action_confirm(cr, uid, [ref('move_test0')], context=context) - - I check that the quantity on hand is 18 and virutal is 13 + I check that the quantity on hand is 18 and virtual is 13 - !python {model: product.product}: | context['location'] = False diff --git a/addons/stock/test/packing.yml b/addons/stock/test/packing.yml new file mode 100644 index 00000000000..016c361ff0c --- /dev/null +++ b/addons/stock/test/packing.yml @@ -0,0 +1,22 @@ +- + Create a new stockable product +- + !record {model: product.product, id: packingtest}: + name: nice product +- + Create an incoming picking for this product of 300 PCE from suppliers to stock +- + !record{model: stock.picking}: | +- + Create move linked to picking +- + !record{model:stock.move, id:} +- + Confirm picking +- + !python {model: stock.picking}: | + self.action_confirm(cr, uid, ref()) +- + Assign picking +- + diff --git a/addons/stock/test/procrule.yml b/addons/stock/test/procrule.yml new file mode 100644 index 00000000000..33bcd1b9c03 --- /dev/null +++ b/addons/stock/test/procrule.yml @@ -0,0 +1,4 @@ +- + Create new product deliverytest +- + !record {} diff --git a/addons/stock/test/shipment.yml b/addons/stock/test/shipment.yml index 07a85f55683..70f9b14c57a 100644 --- a/addons/stock/test/shipment.yml +++ b/addons/stock/test/shipment.yml @@ -100,166 +100,9 @@ shipment = self.pool.get('stock.picking').browse(cr, uid, ref("incomming_shipment")) context.update({'active_model': 'stock.picking', 'active_id': shipment.backorder_id.id, 'active_ids': [shipment.backorder_id.id]}) - - !record {model: stock.invoice.onshipping, id: invoice_incomming}: - group: False -- - !python {model: stock.invoice.onshipping }: | - self.create_invoice(cr, uid, [ref('invoice_incomming')], context=context) -- - I check invoice state of backorder of incomming shipment. -- - !python {model: stock.picking}: | - shipment = self.browse(cr, uid, ref("incomming_shipment")) - assert shipment.backorder_id.invoice_state == 'invoiced', 'Invoice state is not upadted.' -- - I check available stock after received incomming shipping. + I check available stock after received incomming shipping. (removed invoicing here) - !python {model: product.product}: | product = self.browse(cr, uid, ref('product_icecream'), context=context) assert product.qty_available == 140, "Stock does not correspond." - assert product.virtual_available == 0, "Vitual stock does not correspond." -- - I split incomming shipment into lots. each lot contain 10 kgm Ice-cream. -- - !python {model: stock.picking}: | - shipment = self.browse(cr, uid, ref("incomming_shipment")) - move_ids = [x.id for x in shipment.backorder_id.move_lines] - context.update({'active_model': 'stock.move', 'active_id': move_ids[0], 'active_ids': move_ids}) -- - !record {model: stock.move.split, id: split_lot_incomming}: - line_ids: - - name: incoming_lot0 - quantity: 10 - - name: incoming_lot1 - quantity: 10 - - name: incoming_lot2 - quantity: 10 - - name: incoming_lot3 - quantity: 10 - -- - !python {model: stock.move.split }: | - self.split_lot(cr, uid, [ref('split_lot_incomming')], context=context) -- - I check move lines after spliting -- - !python {model: stock.move}: | - lot = self.pool.get('stock.move.split').browse(cr, uid, ref('split_lot_incomming'), context=context) - lot_ids = self.pool.get('stock.production.lot').search(cr, uid, [('name','in',[x.name for x in lot.line_ids])]) - assert len(lot_ids) == 4, 'lots of incomming shipment are not correspond.' - move_ids = self.search(cr, uid, [('location_dest_id','=',ref('location_refrigerator')),('lot_id','in',lot_ids)]) - assert len(move_ids) == 4, 'move lines are not correspond per prodcution lot after splited.' - for move in self.browse(cr, uid, move_ids, context=context): - assert move.lot_id.name in ['incoming_lot0', 'incoming_lot1', 'incoming_lot2', 'incoming_lot3'], "lot does not correspond." - assert move.product_qty == 10, "qty does not correspond per production lot." - context.update({'active_model':'stock.move', 'active_id':move_ids[0],'active_ids': move_ids}) -- - I consume 1 kgm ice-cream from each incoming lots into internal production. -- - !record {model: stock.move.consume, id: consume_lot_incomming}: - product_qty: 1 - location_id: location_refrigerator -- - !python {model: stock.move.consume}: | - self.do_move_consume(cr, uid, [ref('consume_lot_incomming')], context=context) -- - I scrap 10 gm ice-cream from each incoming lots into scrap location. -- - !record {model: stock.move.scrap, id: scrap_lot_incomming}: - product_qty: 0.010 -- - !python {model: stock.move.scrap}: | - self.move_scrap(cr, uid, [ref('scrap_lot_incomming')], context=context) -- - I check stock in scrap location and refrigerator location. -- - !python {model: stock.location}: | - ctx = {'product_id': ref('product_icecream')} - refrigerator_location = self.pool.get('stock.location').browse(cr, uid, ref('location_refrigerator'), context=ctx) - assert refrigerator_location.stock_real == 135.96, 'stock does not correspond in refrigerator location.' - scrapped_location = self.browse(cr, uid, ref('stock_location_scrapped'), context=ctx) - assert scrapped_location.stock_real == 0.010*4, 'scraped stock does not correspond in scrap location.' - -- - I check availabile stock after consumed and scraped. -- - !python {model: product.product}: | - product = self.browse(cr, uid, ref('product_icecream'), context=context) - assert product.qty_available == 135.96, "Stock does not correspond." - assert round(product.virtual_available, 2) == -4.04, "Vitual stock does not correspond." -- - I trace all incoming lots. -- - !python {model: stock.production.lot }: | - lot = self.pool.get('stock.move.split').browse(cr, uid, ref('split_lot_incomming'), context=context) - lot_ids = self.search(cr, uid, [('name', 'in', [x.name for x in lot.line_ids])]) - self.action_traceability(cr, uid, lot_ids, context=context) -- - I check outgoing shipment after stock availablity in refrigerator. -- - !python {model: stock.picking}: | - shipment = self.browse(cr, uid, ref("outgoing_shipment"), context=context) - self.pool.get('stock.move').action_assign(cr, uid, [x.id for x in shipment.move_lines]) #TOFIX: assignment of move lines should be call before testing assigment otherwise picking never gone in assign state - #TOFIX: shipment should be assigned if stock available - #assert shipment.state == "assigned", "Shipment should be assigned." - #for move_line in shipment.move_lines: - # assert move_line.state == "assigned", "Move should be assigned." - self.force_assign(cr, uid, [shipment.id]) -- - I deliver 5kgm Ice-cream to customer so I make partial deliver -- - !python {model: stock.partial.move}: | - context.update({'active_model': 'stock.move', 'active_id': ref('outgoing_shipment_icecream'), 'active_ids': [ref('outgoing_shipment_icecream')]}) -- - !record {model: stock.partial.move, id: partial_outgoing_icecream}: - move_ids: - - quantity: 5 - product_id: product_icecream - product_uom: product.product_uom_kgm - move_id: outgoing_shipment_icecream - location_id: location_refrigerator - location_dest_id: location_delivery_counter -- - !python {model: stock.partial.move }: | - self.do_partial(cr, uid, [ref('partial_outgoing_icecream')], context=context) - -- - I packing outgoing shipment into box per 10kgm with unique tracking lot. -- - !python {model: stock.move}: | - stock_split = self.pool.get('stock.split.into') - move = self.browse(cr, uid, ref('outgoing_shipment_icecream'), context=context) - context.update({'active_model': 'stock.move', 'active_id': move.id, 'active_ids': [move.id]}) - total_qty = move.product_qty - split_qty = 10 - while(total_qty>0): - split_id = stock_split.create(cr, uid, {'quantity': split_qty}, context=context) - stock_split.split(cr, uid, [split_id], context=context) - total_qty -= split_qty -- - I deliver outgoing shipment. -- - !python {model: stock.partial.picking}: | - context.update({'active_model': 'stock.picking', 'active_id': ref('outgoing_shipment'), 'active_ids': [ref('outgoing_shipment')]}) -- - !record {model: stock.partial.picking, id: partial_outgoing}: - picking_id: outgoing_shipment -- - !python {model: stock.partial.picking }: | - self.do_partial(cr, uid, [ref('partial_outgoing')], context=context) - -- - I check outgoing shipment after deliver. -- - !python {model: stock.picking}: | - shipment = self.browse(cr, uid, ref("outgoing_shipment"), context=context) - assert shipment.state == "done", "Shipment should be closed." - for move_line in shipment.move_lines: - assert move_line.state == "done", "Move should be closed." -- - I check availaible stock after deliver. -- - !python {model: product.product}: | - product = self.browse(cr, uid, ref('product_icecream'), context=context) - assert round(product.qty_available, 2) == 5.96, "Stock does not correspond." - assert round(product.virtual_available, 2) == -4.04, "Vitual stock does not correspond." + assert product.virtual_available == 0, "Vitual stock does not correspond." \ No newline at end of file diff --git a/addons/stock_account/__openerp__.py b/addons/stock_account/__openerp__.py index c6cfd7c48ee..371d1b86acd 100644 --- a/addons/stock_account/__openerp__.py +++ b/addons/stock_account/__openerp__.py @@ -44,48 +44,20 @@ Dashboard / Reports for Warehouse Management will include: 'category': 'Hidden', 'sequence': 16, 'demo': [ -# 'stock_demo.xml', -# 'procurement_demo.xml', -# 'stock_orderpoint.xml', -# 'stock_demo.yml', + 'stock_account_demo.xml' ], 'data': [ -# 'security/stock_security.xml', -# 'security/ir.model.access.csv', -# 'stock_data.xml', -# 'wizard/stock_move_view.xml', -# 'wizard/stock_change_product_qty_view.xml', -# 'wizard/stock_partial_picking_view.xml', -# 'wizard/stock_partial_move_view.xml', -# 'wizard/stock_fill_inventory_view.xml', + 'stock_account_data.xml', 'wizard/stock_invoice_onshipping_view.xml', -# 'wizard/stock_inventory_merge_view.xml', -# 'wizard/stock_location_product_view.xml', -# 'wizard/stock_splitinto_view.xml', -# 'wizard/stock_inventory_line_split_view.xml', 'wizard/stock_change_standard_price_view.xml', -# 'wizard/stock_return_picking_view.xml', -# 'wizard/make_procurement_view.xml', -# 'wizard/mrp_procurement_view.xml', -# 'wizard/orderpoint_procurement_view.xml', -# 'stock_workflow.xml', -# 'stock_incoterms.xml', -# 'stock_report.xml', -# 'stock_view.xml', -# 'stock_sequence.xml', -# 'product_data.xml', + 'product_data.xml', 'product_view.xml', -# 'partner_view.xml', -# 'report/report_stock_move_view.xml', -# 'report/report_stock_view.xml', -# 'board_warehouse_view.xml', -# 'res_config_view.xml', + + 'stock_account_view.xml', 'valuationandcostmethod.yml', ], 'test': [ -# 'test/inventory.yml', -# 'test/move.yml', -# 'test/shipment.yml', + ], 'installable': True, 'application': True, diff --git a/addons/stock_account/product_data.xml b/addons/stock_account/product_data.xml index ae5a3478500..49a065488a1 100644 --- a/addons/stock_account/product_data.xml +++ b/addons/stock_account/product_data.xml @@ -5,7 +5,7 @@ property_stock_journal - + diff --git a/addons/stock_account/stock_account_view.xml b/addons/stock_account/stock_account_view.xml index 661f623e5dd..0586843c5ad 100644 --- a/addons/stock_account/stock_account_view.xml +++ b/addons/stock_account/stock_account_view.xml @@ -6,7 +6,7 @@ stock.location.form.inherit stock.location - + @@ -17,20 +17,17 @@ - + + - - stock.picking.tree.inherit - stock.picking.in - - - - - - - stock.picking.in.search.inherit stock.picking.in diff --git a/addons/stock_complex_routes/test/dropship.yml b/addons/stock_complex_routes/test/dropship.yml new file mode 100644 index 00000000000..4a465327f9f --- /dev/null +++ b/addons/stock_complex_routes/test/dropship.yml @@ -0,0 +1,21 @@ +- + Create new product candy without any routes +- + !record {model:product.product, id:} +- + Create a sales order with a line of 200 PCE incoming shipment, with route_id drop shipping +- + !record {model: sale.order} + +- + Confirm sales order +- + !python{model: sale.order}: | + +- + Run schedulers +- + !python{model: procurement.order, id: }: | + +- +