diff --git a/addons/product/product_demo.xml b/addons/product/product_demo.xml index e97169fa851..2e8be677945 100644 --- a/addons/product/product_demo.xml +++ b/addons/product/product_demo.xml @@ -321,19 +321,7 @@ product - - ICE - buy - 100.0 - 70.0 - - - make_to_stock - 1.0 - Ice Cream - product - - + TOW1 37.5 diff --git a/addons/stock/__openerp__.py b/addons/stock/__openerp__.py index 620accccdd3..0d16ec746cb 100644 --- a/addons/stock/__openerp__.py +++ b/addons/stock/__openerp__.py @@ -51,7 +51,7 @@ Thanks to the double entry management, the inventory controlling is powerful and "init_xml" : [], "demo_xml" : [ "stock_demo.xml", - "stock_demo_picking.yml", + "stock_demo2.xml", ], "update_xml" : [ "security/stock_security.xml", @@ -82,10 +82,9 @@ Thanks to the double entry management, the inventory controlling is powerful and "board_warehouse_view.xml", ], 'test': [ - 'test/stock_physical_inventory.yml', - 'test/stock_update.yml', - 'test/stock_demo_backorder.yml', - 'test/cancel_stock.yml', + 'test/stock_demo.yml', + 'test/opening_stock.yml', + 'test/shipment.yml', 'test/stock_report.yml', ], 'installable': True, diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 0536c725638..e5e4c895197 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -2308,6 +2308,7 @@ class stock_move(osv.osv): @param context: context arguments @return: Scraped lines """ + #quantity should in MOVE UOM if quantity <= 0: raise osv.except_osv(_('Warning!'), _('Please provide a positive quantity to scrap!')) res = [] @@ -2408,6 +2409,7 @@ class stock_move(osv.osv): @param context: context arguments @return: Consumed lines """ + #quantity should in MOVE UOM if context is None: context = {} if quantity <= 0: @@ -2673,7 +2675,7 @@ class stock_inventory(osv.osv): self.write(cr, uid, [inv.id], {'state':'draft'}, context=context) return True - def action_cancel_inventary(self, cr, uid, ids, context=None): + def action_cancel_inventory(self, cr, uid, ids, context=None): """ Cancels both stock move and inventory @return: True """ diff --git a/addons/stock/stock_demo.xml b/addons/stock/stock_demo.xml index 24b485d120f..3940804eb5c 100644 --- a/addons/stock/stock_demo.xml +++ b/addons/stock/stock_demo.xml @@ -9,14 +9,6 @@ - - Cold Storage - - fixed - - auto - internal - IT Suppliers @@ -50,14 +42,7 @@ Shelf 1 - - Convenient Store - - auto - fixed - internal - - + diff --git a/addons/stock/stock_demo2.xml b/addons/stock/stock_demo2.xml new file mode 100644 index 00000000000..61a976db30d --- /dev/null +++ b/addons/stock/stock_demo2.xml @@ -0,0 +1,109 @@ + + + + + Refrigerator + inventory + + + Delivery Counter + internal + + + Small Refrigerator + internal + + + + Convenient Store + auto + fixed + internal + + + + 001 + buy + 100.0 + 70.0 + + + make_to_stock + Ice Cream + product + + + + + + 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. + + + + + Ice Cream Shop + + + + + + + Inventory for icecream + + + Lot0 for Ice cream + + + + Lot1 for Ice cream + + + + + #lot0 : 50 kgm + + + + 50.0 + + + + #lot1 : 40 kgm + + + + 40.0 + + + + + + + out + + + + Ice-cream + + + + 130.0 + + + + + + + + + + Ice-cream + + + + 50.0 + + + + + diff --git a/addons/stock/stock_demo_picking.yml b/addons/stock/stock_demo_picking.yml deleted file mode 100644 index 6301ab7a0cb..00000000000 --- a/addons/stock/stock_demo_picking.yml +++ /dev/null @@ -1,25 +0,0 @@ -- - !record {model: stock.picking, id: stock_picking_1}: - type: out - company_id: base.main_company - address_id: res_partner_address_fabien0 -- - !record {model: stock.move, id: stock_move_1}: - product_id: product.product_product_cpu1 - 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: CPU1, Processor AMD Athlon XP 1800 - picking_id: stock_picking_1 -- - !record {model: stock.move, id: stock_move_2}: - product_id: product.product_product_cpu3 - 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: CPU3, Processor AMD Athlon XP 1800 - picking_id: stock_picking_1 diff --git a/addons/stock/test/opening_stock.yml b/addons/stock/test/opening_stock.yml new file mode 100644 index 00000000000..fc3dcc37289 --- /dev/null +++ b/addons/stock/test/opening_stock.yml @@ -0,0 +1,131 @@ +- + I update the price of the Ice-cream. +- + !python {model: stock.change.standard.price}: | + context.update({'active_model':'product.product', 'active_id': ref('product_icecream'), 'active_ids':[ref('product_icecream')]}) +- + !record {model: stock.change.standard.price, id: change_price}: + new_price: 120 +- + !python {model: stock.change.standard.price}: | + self.change_price(cr, uid, [ref('change_price')], context=context) +- + I check price of Ice-cream after update price. +- + !python {model: product.product}: | + product = self.browse(cr, uid, ref('product_icecream'), context=context) + assert product.standard_price == 120, "Price is not updated." +- + I update the current stock of the Ice-cream with 10 kgm in Small Refrigerator in lot0. +- + !record {model: stock.change.product.qty, id: change_qty}: + location_id: location_refrigerator_small + new_quantity: 10 + product_id: product_icecream + prodlot_id': lot_icecream_1 +- + !python {model: stock.change.product.qty}: | + self.change_product_qty(cr, uid, [ref('change_qty')], context=context) +- + I check available stock of Ice-cream after update stock. +- + !python {model: product.product}: | + product = self.browse(cr, uid, ref('product_icecream'), context=context) + assert product.qty_available == 10, "Stock is not updated." +- + I fill inventory line. +- + !python {model: stock.fill.inventory}: | + context.update({'active_model': 'stock.inventory', 'active_id': ref('stock_inventory_icecream'), 'active_ids': [ref('stock_inventory_icecream')]}) +- + !record {model: stock.fill.inventory, id: fill_inventory}: + location_id: location_refrigerator + recursive: True +- + !python {model: stock.fill.inventory }: | + self.fill_inventory(cr, uid, [ref('fill_inventory')], context=context) +- + I split inventory line. +- + !python {model: stock.inventory.line.split}: | + context.update({'active_model': 'stock.inventory.line', 'active_id': ref('stock_inventory_line_icecream_lot0'), 'active_ids': [ref('stock_inventory_line_icecream_lot0')]}) +- + !record {model: stock.inventory.line.split, id: split_inventory_lot0}: + use_exist: True + line_exist_ids: + - quantity: 10 + product_id: product_icecream + prod_lot_id: lot_icecream_0 + product_uom: product.product_uom_kgm + location_id: location_refrigerator +- + !python {model: stock.inventory.line.split }: | + self.split(cr, uid, [ref('split_inventory_lot0')], context=context) +- + I merge inventory. +- + !python {model: stock.inventory.merge }: | + context.update({'active_model': 'stock.inventory', 'active_id': ref('stock_inventory_icecream'), 'active_ids': [ref('stock_inventory_icecream')]}) +- + !record {model: stock.inventory.merge, id: merge_inventory}: +- + !python {model: stock.inventory.merge }: | + self.do_merge(cr, uid, [ref('merge_inventory')], context=context) +- + I cancel inventory. +- + !python {model: stock.inventory}: | + self.action_cancel_inventory(cr, uid, [ref('stock_inventory_icecream')]) +- + I reset to draft inventory. +- + !python {model: stock.inventory}: | + self.action_cancel_draft(cr, uid, [ref('stock_inventory_icecream')]) +- + I confirm physical inventory of Ice-cream which are came in different lots. +- + !python {model: stock.inventory}: | + self.action_confirm(cr, uid, [ref('stock_inventory_icecream')], context=context) +- + I check move details after confirmed physical inventory. +- + !python {model: stock.inventory}: | + inventory = self.browse(cr, uid, ref('stock_inventory_icecream'), context=context) + assert len(inventory.move_ids) == len(inventory.inventory_line_id), "moves are not correspond." + for move_line in inventory.move_ids: + for line in inventory.inventory_line_id: + if move_line.product_id.id == line.product_id.id: + location_id = line.product_id.product_tmpl_id.property_stock_inventory.id + assert move_line.product_qty == line.product_qty, "Qty is not correspond." + assert move_line.product_uom.id == line.product_uom.id, "UOM is not correspond." + assert move_line.prodlot_id.id == line.prodlot_id.id, "Production lot is not correspond." + assert move_line.date == inventory.date, "Date is not correspond." + assert move_line.location_id.id == location_id, "Source location is not correspond." + assert move_line.location_dest_id.id == line.location_id.id, "Destination location is not correspond." +- + Now I check vitual stock of Ice-cream after confirmed physical inventory. +- + !python {model: product.product}: | + product = self.browse(cr, uid, ref('product_icecream'), context=context) + product.virtual_available == 100, "Vitual stock is not updated." +- + I close physical inventory of Ice-cream. +- + !python {model: stock.inventory}: | + self.action_done(cr, uid, [ref('stock_inventory_icecream')], context=context) +- + I check closed move and real stock of Ice-cream after closed physical inventory. +- + !python {model: stock.inventory}: | + inventory = self.browse(cr, uid, ref('stock_inventory_icecream'), context=context) + assert inventory.state == 'done', "inventory is not closed." + for move_line in inventory.move_ids: + assert move_line.state == 'done', "Move is not closed." + product = self.pool.get('product.product').browse(cr, uid, ref('product_icecream'), context=context) + product.qty_available == 100, "Real stock is not updated." +- + I check stock in lot. +- + !python {model: stock.production.lot}: | + lot = self.browse(cr, uid, ref('lot_icecream_0'), context=context) + assert lot.stock_available == 60, "Stock in lot is not correspond." diff --git a/addons/stock/test/shipment.yml b/addons/stock/test/shipment.yml new file mode 100644 index 00000000000..a97d2b018d8 --- /dev/null +++ b/addons/stock/test/shipment.yml @@ -0,0 +1,222 @@ +- + I confirm outgoing shipment of 130 kgm Ice-cream. +- + !workflow {model: stock.picking, action: button_confirm, ref: outgoing_shipment} +- + I check shipment details after confirmed. +- + !python {model: stock.picking}: | + shipment = self.browse(cr, uid, ref("outgoing_shipment")) + assert shipment.state == "confirmed", "Shipment should be confirmed." + for move_line in shipment.move_ids: + assert move_line.state == "confirmed", "Move should be confirmed." + +- + Now I check vitual stock of Ice-cream after confirmed outgoing shipment. +- + !python {model: product.product}: | + product = self.browse(cr, uid, ref('product_icecream'), context=context) + product.virtual_available == -30, "Vitual stock is not updated." + +- + I confirm incomming shipment of 50 kgm Ice-cream. +- + !workflow {model: stock.picking, action: button_confirm, ref: incoming_shipment} +- + I receive 40kgm Ice-cream so I make backorder of incomming shipment for 10 kgm. +- + !python {model: stock.partial.picking}: | + context.update({'active_model': 'stock.picking', 'active_id': ref('incoming_shipment'), 'active_ids': [ref('incoming_shipment')]}) +- + !record {model: stock.partial.picking, id: partial_incomming}: + move_ids: + - quantity: 40 + product_id: product_icecream + product_uom: product.product_uom_kgm + move_id: incomming_shipment_icecream + location_id: location_convenience_shop + location_dest_id: location_refrigerator +- + !python {model: stock.partial.picking }: | + self.do_partial(cr, uid, [ref('partial_incomming')], context=context) +- + I check backorder shipment after received partial shipment. +- + !python {model: stock.picking}: | + shipment = self.browse(cr, uid, ref("incoming_shipment")) + assert shipment.backorder_id, "Backorder should be created after partial shipment." +- + I return backorder shipment. +- + !python {model: stock.return.picking}: | + shipment = self.browse(cr, uid, ref("incoming_shipment")) + context.update({'active_model': 'stock.picking', 'active_id': shipment.backorder_id.id, 'active_ids': [shipment.backorder_id.id]}) +- + !record {model: stock.return.picking, id: return_incomming} +- + !python {model: stock.return.picking }: | + self.create_returns(cr, uid, [ref('return_incomming')], context=context) +- + I cancel backorder shipment. +- + !python {model: stock.picking}: | + shipment = self.browse(cr, uid, ref("incoming_shipment")) + shipment.backorder_id.action_cancel(context=context) +- + I make invoice of incomming shipment. +- + !python {model: stock.invoice.onshipping}: | + shipment = self.browse(cr, uid, ref("incoming_shipment")) + context.update({'active_model': 'stock.picking', 'active_id': shipment.id, 'active_ids': [shipment.id]}) +- + !record {model: stock.invoice.onshipping, id: invoice_incomming} +- + !python {model: stock.invoice.onshipping }: | + self.create_invoice(cr, uid, [ref('invoice_incomming')], context=context) + +- + I check availabile stock after received incomming shipping. +- + !python {model: product.product}: | + product = self.browse(cr, uid, ref('product_icecream'), context=context) + assert product.qty_available == 140, "Stock is not correspond." + assert product.virtual_available == 10, "Vitual stock is not correspond." + +- + I split incomming shipment into lots. each lot contain 10 kgm Ice-cream. +- + !python {model: stock.move.split}: | + context.update({'active_model': 'stock.move', 'active_id': ref('incomming_shipment_icecream'), 'active_ids': [ref('incomming_shipment_icecream')]}) +- + !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 consume 1 kgm ice-cream from each incoming lots into internal production. +- + !python {model: stock.move.consume}: | + lot = self.pool.get(stock.move.split).browse(cr, uid, ref('split_lot_incomming'), context=context) + move_ids = self.pool.get('stock.move').search(cr, uid, [('prod_lot_id','in',[x.name for x in lot.line_ids])]) + context.update({'active_model':'stock.move', 'active_id':move_ids[0],'active_ids': move_ids}) +- + !record {model: stock.move.consume, id: consume_lot_incomming}: + product_qty: 1 + location_id: ref('location_production') +- + !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. +- + !python {model: stock.move.scrap}: | + lot = self.pool.get(stock.move.split).browse(cr, uid, ref('split_lot_incomming'), context=context) + move_ids = self.pool.get('stock.move').search(cr, uid, [('prod_lot_id','in',[x.name for x in lot.line_ids])]) + context.update({'active_model':'stock.move', 'active_id':move_ids[0],'active_ids': move_ids}) +- + !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 scraped stock in scrap location and consume stock in production location. +- + !python {model: stock.location}: | + ctx = {'product_id': ref('product_icecream')} + scrapped_location = self.browse(cr, uid, ref('stock_location_scrapped'), context=ctx) + assert scrapped_location.stock_real == 0.010*5, 'scraped stock is not correspond in scrap location.' + production_location = self.browse(cr, uid, ref('location_production'), context=ctx) + assert production_location.stock_real == 1*5, 'consume stock is not correspond in production 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 == 136, "Stock is not correspond." + assert product.virtual_available == 6, "Vitual stock is 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. +- + !python {model: stock.picking}: | + import netsvc + wf_service = netsvc.LocalService("workflow") + wf_service.trg_write(uid, 'stock.picking', ref("outgoing_shipment"), cr) + shipment = self.browse(cr, uid, ref("outgoing_shipment"), context=context) + assert shipment.state == "assigned", "Shipment should be assigned." + for move_line in shipment.move_ids: + assert move_line.state == "assigned", "Move should be assigned." +- + 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} +- + !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_ids: + assert move_line.state == "done", "Move should be closed." +- + I check availabile stock after deliver. +- + !python {model: product.product}: | + product = self.browse(cr, uid, ref('product_icecream'), context=context) + assert product.qty_available == 6, "Stock is not correspond." + assert product.virtual_available == 6, "Vitual stock is not correspond." diff --git a/addons/stock/test/stock_demo.yml b/addons/stock/test/stock_demo.yml new file mode 100644 index 00000000000..3b97f61cda3 --- /dev/null +++ b/addons/stock/test/stock_demo.yml @@ -0,0 +1,14 @@ +- + !record {model: stock.inventory.line, id: stock_inventory_line_icecream_lot0}: + product_id: product_icecream + product_uom: product.product_uom_kgm + product_qty: 50 +- + !record {model: stock.picking, id: outgoing_shipment}: + partner_id: base.res_partner_agrolait +- + !record {model: stock.move, id: outgoing_shipment_icecream}: + product_id: product_icecream + product_uom: product.product_uom_kgm + product_qty: 130 + diff --git a/addons/stock/test/stock_demo_backorder.yml b/addons/stock/test/stock_demo_backorder.yml deleted file mode 100644 index 43aeeb93a09..00000000000 --- a/addons/stock/test/stock_demo_backorder.yml +++ /dev/null @@ -1,106 +0,0 @@ -- - In order to test partial delivery and back orders, I select delivery order and check process on it. -- - !record {model: stock.picking, id: stock_picking_1}: - invoice_state: '2binvoiced' -- - I confirm the Delivery order and make it available . -- - !python {model: stock.picking}: | - self.draft_force_assign(cr, uid, [ref('stock.stock_picking_1')], {}) - self.draft_validate(cr, uid, [ref('stock.stock_picking_1')], {}) - try: - self.action_assign(cr, uid, [ref('stock.stock_picking_1')], {}) - except: - pass - self.force_assign(cr, uid, [ref('stock.stock_picking_1')], {}) -- - I add a new move line in the delivery order. -- - !record {model: stock.move, id: stock_move_3}: - product_id: product.product_product_fan2 - product_qty: 7.0 - location_dest_id: stock.stock_location_customers - location_id: stock.stock_location_stock - picking_id: stock_picking_1 -- - Now, check the product availability for newly created move. -- - !python {model: stock.move}: | - self.action_assign(cr, uid, [ref('stock_move_3')]) -- - I make partial delivery for the delivery order. -- - !python {model: stock.picking}: | - result = self.action_process(cr, uid, [ref('stock.stock_picking_1')], {})['res_id'] - pick = self.pool.get('stock.partial.picking').browse(cr, uid, result, {}) - pick_line = self.pool.get('stock.partial.picking.line') - for line in pick.move_ids: - if line.product_id.id == ref('product.product_product_cpu3'): - pick_line.write(cr, uid, [line.id], {'quantity': 0.0}, {}) - elif line.product_id.id == ref('product.product_product_cpu1'): - pick_line.write(cr, uid, [line.id], {'quantity': 7.0}, {}) - elif line.product_id.id == ref('product.product_product_fan2'): - pick_line.write(cr, uid, [line.id], {'quantity': 3.0}, {}) - pick_line.create(cr, uid, { - 'product_id': ref('product.product_product_pc1'), - 'quantity': 2.0, - 'product_uom': ref('product.product_uom_unit'), - 'location_id': ref('stock.stock_location_stock'), - 'location_dest_id': ref('stock.stock_location_customers'), - 'wizard_id': result - }, {}) - self.pool.get('stock.partial.picking').do_partial(cr, uid, [result], {}) - -- - I Create Invoice for this picking. -- - !python {model: stock.invoice.onshipping}: | - ctx = {"active_model":"stock.picking", "active_ids": [ref("stock.stock_picking_1")], "active_id":ref("stock.stock_picking_1"), "search_default_available": 1, "inv_type": "in_invoice" , "contact_display": "partner_address", } - context = ctx - invoice_line_id = self.create(cr, uid,{}, context) - self.open_invoice(cr, uid, [invoice_line_id], context) - self._get_journal_id(cr, uid, context) -- - I check the backorder and its moves. -- - !python {model: stock.picking}: | - 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 %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 %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: - assert line.product_qty == 0.0, "Wrong quantity for %s back order" % (line.product_id.code,) -- - I check the backorder. -- - !python {model: stock.picking}: | - pick = self.browse(cr, uid, ref('stock.stock_picking_1')) - stock = self.pool.get('stock.move') - assert pick.state == 'assigned',"After partial picking the remaining product's delivery order must be in 'Ready to process' state" - assert pick.backorder_id.state == 'done',"The backorder state should be 'Done'" - done_move = stock.search(cr, uid, [('picking_id','=',pick.backorder_id.id)]) - assign_move = stock.search(cr, uid, [('picking_id','=',pick.id)]) - for move in stock.browse(cr, uid, done_move): - assert move.state == 'done',"Stock move of %s picking should be in 'Done' state"%(move.picking_id.name) - for move in stock.browse(cr, uid, assign_move): - assert move.state == 'assigned' or 'draft',"Stock move of %s picking should be in 'Available' state"%(move.picking_id.name) -- - After the partial picking of delivery order, I check the stock moves. -- - !python {model: stock.picking}: | - pick = self.browse(cr, uid, ref('stock.stock_picking_1')) - stock = self.pool.get('stock.move') - assert pick.state == 'assigned',"After partial picking the remaining product's delivery order must be in 'Ready to process' state" - assert pick.backorder_id.state == 'done',"The backorder state should be 'Done'" - done_move = stock.search(cr, uid, [('picking_id','=',pick.backorder_id.id)]) - assign_move = stock.search(cr, uid, [('picking_id','=',pick.id)]) - for move in stock.browse(cr, uid, done_move): - assert move.state == 'done',"Stock move of %s picking should be in 'Done' state"%(move.picking_id.name) - for move in stock.browse(cr, uid, assign_move): - assert move.state == 'assigned' or 'draft',"Stock move of %s picking should be in 'Available' state"%(move.picking_id.name) - diff --git a/addons/stock/test/stock_physical_inventory.yml b/addons/stock/test/stock_physical_inventory.yml deleted file mode 100644 index 8b5ed755ec1..00000000000 --- a/addons/stock/test/stock_physical_inventory.yml +++ /dev/null @@ -1,45 +0,0 @@ -- - In order to test the stock module, I need to create initial physical inventory. -- - I create a physical inventory and change the product quantity zero by making a physical inventory. -- - !record {model: stock.inventory, id: stock_physical_inventory0}: - name: Physical inventory -- - I define and fill the inventory. -- - !python {model: stock.fill.inventory}: | - ids = self.create(cr, uid, {'location_id': ref('stock_location_components'),'set_stock_zero': True}) - self.view_init(cr, uid, ["set_stock_zero", "location_id", "recursive"]) - self.fill_inventory(cr, uid, [ids],{"full": "1", "active_model": "stock.inventory","active_id": ids,"active_ids":[ref('stock_physical_inventory0')]}) -- - I confirm the inventory. -- - !python {model: stock.inventory}: | - inventory = self.browse(cr, uid, [ref('stock_physical_inventory0')])[0] - self.action_confirm(cr,uid,[inventory.id]) - assert inventory.state == 'confirm',"Inventory should be in 'Confirmed' state." - if inventory.inventory_line_id: - for line in inventory.inventory_line_id: - assert line.product_qty == 0.0,"Product quantity should be Zero." - assert len(inventory.move_ids) >= 1,"Move should be created after confirmed inventory" - for move in inventory.move_ids: - assert move.location_id.id == ref('stock_location_components'),"Source location of move is not corresponding." - assert move.location_dest_id.id == ref('location_inventory'),"Destination location of move is not corresponding." -- - I validate the inventory after confirmation. -- - !python {model: stock.inventory}: | - inventory = self.browse(cr, uid, [ref('stock_physical_inventory0')])[0] - self.action_done(cr,uid,[inventory.id]) - assert inventory.state == 'done',"Inventory should be in 'Done' state" -- - I cancel the Inventory. -- - !python {model: stock.inventory}: | - self.action_cancel_inventary(cr,uid,[ref('stock_physical_inventory0')]) -- - I change inventory state to Draft. -- - !python {model: stock.inventory}: | - self.action_cancel_draft(cr,uid,[ref('stock_physical_inventory0')]) diff --git a/addons/stock/test/stock_report.yml b/addons/stock/test/stock_report.yml index ef16cb31004..5c5932446eb 100644 --- a/addons/stock/test/stock_report.yml +++ b/addons/stock/test/stock_report.yml @@ -1,42 +1,41 @@ - - - In order to test the PDF reports defined on a stock, I print a Stock Overviewall(children) report. + I print a stock overview report of location. - !python {model: stock.location}: | import netsvc, tools, os - (data, format) = netsvc.LocalService('report.lot.stock.overview_all').create(cr, uid, [ref('stock.stock_location_stock')], {}, {}) - if tools.config['test_report_directory']: - file(os.path.join(tools.config['test_report_directory'], 'stock-overviewall'+format), 'wb+').write(data) -- - In order to test the PDF reports defined on stock inventory, I print a Stock Inventory Move report. -- - !python {model: stock.inventory}: | - import netsvc, tools, os - (data, format) = netsvc.LocalService('report.stock.inventory.move').create(cr, uid, [ref('stock.stock_inventory_0')], {}, {}) - if tools.config['test_report_directory']: - file(os.path.join(tools.config['test_report_directory'], 'stock-stock_inventory_move.'+format), 'wb+').write(data) -- - In order to test the PDF reports defined on a stock, I print a stock overview report. -- - !python {model: stock.location}: | - import netsvc, tools, os - (data, format) = netsvc.LocalService('report.lot.stock.overview').create(cr, uid, [ref('stock.stock_location_14')], {}, {}) + (data, format) = netsvc.LocalService('report.lot.stock.overview').create(cr, uid, [ref('location_refrigerator')], {}, {}) if tools.config['test_report_directory']: file(os.path.join(tools.config['test_report_directory'], 'stock-overview'+format), 'wb+').write(data) - - In order to test the PDF reports defined on a stock, I print a Delivery order List report. + I print a Stock Overview report of location with child location. +- + !python {model: stock.location}: | + import netsvc, tools, os + (data, format) = netsvc.LocalService('report.lot.stock.overview_all').create(cr, uid, [ref('location_refrigerator')], {}, {}) + if tools.config['test_report_directory']: + file(os.path.join(tools.config['test_report_directory'], 'stock-overviewall'+format), 'wb+').write(data) +- + I print a Stock Inventory report. +- + !python {model: stock.inventory}: | + import netsvc, tools, os + (data, format) = netsvc.LocalService('report.stock.inventory.move').create(cr, uid, [ref('stock_inventory_icecream')], {}, {}) + if tools.config['test_report_directory']: + file(os.path.join(tools.config['test_report_directory'], 'stock-stock_inventory_move.'+format), 'wb+').write(data) +- + I print a outgoing shipment report. - !python {model: stock.picking}: | import netsvc, tools, os - (data, format) = netsvc.LocalService('report.stock.picking.list').create(cr, uid, [ref('stock.stock_picking_1')], {}, {}) + (data, format) = netsvc.LocalService('report.stock.picking.list').create(cr, uid, [ref('outgoing_shipment')], {}, {}) if tools.config['test_report_directory']: file(os.path.join(tools.config['test_report_directory'], 'stock-picking_list'+format), 'wb+').write(data) - - In order to test the PDF reports defined on a stock, I print product stock Report. + I print stock Report. - !python {model: product.product}: | import netsvc, tools, os - (data, format) = netsvc.LocalService('report.stock.product.history').create(cr, uid, [ref('product.product_product_pc1')], {}, {}) + (data, format) = netsvc.LocalService('report.stock.product.history').create(cr, uid, [ref('product_icecream')], {}, {}) if tools.config['test_report_directory']: file(os.path.join(tools.config['test_report_directory'], 'stock-product_stock_report.'+format), 'wb+').write(data) diff --git a/addons/stock/test/stock_update.yml b/addons/stock/test/stock_update.yml deleted file mode 100644 index 5b68fe4e529..00000000000 --- a/addons/stock/test/stock_update.yml +++ /dev/null @@ -1,92 +0,0 @@ -- - I update the current stock of the product. -- - I assign the location. -- - !record {model: stock.warehouse, id: stock.warehouse0}: - lot_stock_id: cold_location_1 -- - I create stock production lot for product. -- - !record {model: stock.production.lot, id: stock_production_lot0}: - product_id: product.product_product_ice - date: !eval time.strftime('%Y-%m-%d %H:%M:%S') - name: 0000001 -- - I update product quantity and check the stock moves are properly done or not. -- - !python {model: product.product}: | - change_qty = self.pool.get('stock.change.product.qty') - product = self.browse(cr, uid, ref('product.product_product_ice')) - ids = change_qty.create(cr, uid, {'location_id' : ref('cold_location_1'), 'new_quantity': 5, 'product_id': product.id, 'prodlot_id': ref('stock.stock_production_lot0')}) - change_qty.change_product_qty(cr, uid, [ids], {'active_model':'product.product', 'active_id': product.id, 'active_ids':[product.id]}) - assert product.qty_available == 5,"Product quantity is not updated." -- - I trace the stock production lot for 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 that physical inventory created. -- - !python {model: stock.inventory.line}: | - ids = self.search(cr, uid, [('product_id','=',ref('product.product_product_ice'))]) - inventory = self.browse(cr, uid, ids)[0] - assert inventory.product_qty == 5,'Product quantity is not corresponding.' - assert inventory.location_id.id == ref('cold_location_1'), 'Location is not corresponding.' - assert inventory.state == 'done', "State should be in 'Done' state." -- - I check that stock moves created. -- - !python {model: stock.move}: | - ids = self.search(cr, uid, [('product_id','=',ref('product.product_product_ice'))]) - assert [x.state for x in self.browse(cr, uid, ids) if x.state == 'done'], 'Stock moves should be done!' - context = {"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":ids, "active_id":ids[0]} - self.action_partial_move(cr, uid , ids, context) -- - I check stock moves of product. -- - !python {model: stock.move}: | - ids = self.search(cr, uid, [('product_id','=',ref('product.product_product_ice'))]) - for move in self.browse(cr, uid, ids): - assert move.product_qty >= 1,"Product is not corresponding." - if move.location_id.id == ref('stock_physical_inventory0'): - assert move.location_dest_id.id == ref('convenience_location_stock'),"Destination location must be 'Convenient Store'" - if move.location_id.id == ref('convenience_location_stock'): - assert move.location_dest_id.id == ref('cold_location_1'),"Destination location must be 'Cold Storage' because the source location is 'Convenient Store'" - if move.location_id.id == ref('cold_location_1'): - assert move.location_dest_id.id == ref('stock_location_customers'),"Destination location must be 'Customers' because the source location is 'Cold Storage'" -- - I create a move and scrap some quantities from it. -- - !python {model: stock.move.scrap}: | - ids = self.pool.get('stock.move').search(cr, uid, [('product_id','=',ref('product.product_product_ice')),('location_dest_id','=',ref('stock_location_customers'))]) - self.pool.get('stock.move').browse(cr, uid, ids)[0] - context = {'active_model':'stock.move', 'active_id':ids[0],'active_ids': ids} - values = self.default_get(cr, uid, ['location_id','product_id','product_uom','product_qty'], context) - scrap_ids = self.create(cr, uid, values) - self.move_scrap(cr, uid, [scrap_ids], context) -- - I check scraped move details. -- - !python {model: stock.move}: | - ids = self.search(cr, uid, [('product_id','=',ref('product.product_product_ice')),('location_dest_id','=',ref('stock_location_customers'))]) - for scrap_move in self.browse(cr, uid, ids): - if scrap_move.product_qty == 5.0 and scrap_move.location_dest_id == ref('stock_location_scrapped'): - assert scrap_move.state == 'done',"The scraped move should be in 'Done' state." -- - I split a move in to different quantities. -- - !python {model: stock.move }: | - import time - ids = self.pool.get('stock.move').search(cr, uid, [('product_id','=',ref('product.product_product_ice')),('location_dest_id','=',ref('stock_location_customers'))]) - old_move=self.browse(cr,uid,ids)[0] - context = {'active_model': 'stock.move','active_id':ids[0],'active_ids': ids} - tracking_id = self.pool.get('stock.tracking').create(cr, uid, {'name': '0000007', 'date': time.strftime('%Y-%m-%d %H:%M:%S')}) - self.write(cr, uid, ids, {'tracking_id': tracking_id}) - split_obj=self.pool.get('stock.split.into') - split_id = split_obj.create(cr, uid, {'quantity': 1 }) - split_obj.split(cr, uid, [split_id], context) - all_ids = self.search(cr, uid, [('product_id','=',ref('product.product_product_ice'))]) - new_move=self.browse(cr,uid,all_ids)[-1] - assert not old_move.tracking_id == new_move.tracking_id,"After spliting the move, new move should be created with new pack." diff --git a/addons/stock/wizard/stock_move.py b/addons/stock/wizard/stock_move.py index a61784f7a6b..e7cd5a4e41c 100644 --- a/addons/stock/wizard/stock_move.py +++ b/addons/stock/wizard/stock_move.py @@ -34,6 +34,7 @@ class stock_move_consume(osv.osv_memory): 'location_id': fields.many2one('stock.location', 'Location', required=True) } + #TOFIX: product_uom should not have differemt category of default UOM of product. Qty should be convert into UOM of original move line before going in consume and scrap def default_get(self, cr, uid, fields, context=None): """ Get default values @param self: The object pointer.