- In order to test the stock_location module, I create a product and define its pulled flows. If a product is needed either in Chicago Shop or in Birmingham shop, there must be a incomming move from transit location to these shops, and an outgoing move from Stock to the transit location. - !record {model: product.product, id: product_product_hpcdwriters01}: list_price: 1000.0 mes_type: fixed name: HP CD writers type: product uom_id: product.product_uom_unit uom_po_id: product.product_uom_unit property_account_expense: account.a_expense property_account_income: account.rev flow_pull_ids: - invoice_state: none location_id: stock.stock_location_shop0 location_src_id: stock.stock_location_intermediatelocation0 name: E001 picking_type: in procure_method: make_to_order type_proc: move company_id: stock.res_company_1 - invoice_state: none location_id: stock.stock_location_shop1 location_src_id: stock.stock_location_intermediatelocation0 name: E002 picking_type: in procure_method: make_to_order type_proc: move company_id: stock.res_company_2 - invoice_state: none location_id: stock.stock_location_intermediatelocation0 location_src_id: stock.stock_location_stock name: E003 type_proc: move picking_type: out company_id: base.main_company property_stock_inventory: stock.location_inventory property_stock_procurement: stock.location_procurement property_stock_production: stock.location_production qty_available: 15 - I create a procurement order. - !record {model: procurement.order, id: procurement_order_test0}: company_id: stock.res_company_1 date_planned: !eval time.strftime('%Y-%m-%d %H:%M:%S') location_id: stock.stock_location_shop0 name: Testing pulled flow priority: '1' procure_method: make_to_order product_id: product_product_hpcdwriters01 product_qty: 5.0 product_uom: product.product_uom_unit product_uos: product.product_uom_unit product_uos_qty: 0.0 - I confirm the procurement order. - !workflow {model: procurement.order, action: button_confirm, ref: procurement_order_test0} - I launch the scheduler to compute procurement. - !python {model: procurement.order.compute.all}: | proc_obj = self.pool.get('procurement.order') proc_obj._procure_confirm(cr,uid, ids=[ref('procurement_order_test0')]) - I check the new procurement order has been created . - !python {model: procurement.order }: | procurement_ids = self.search(cr, uid, [('name','=','E001')]) assert len(procurement_ids), "Procurement order hasn't been created." - I check the Outgoing Picking is created for source location Stock and destination Chicago shop. - !python {model: stock.picking }: | in_picking_id = self.search(cr, uid, [('origin','=','Testing pulled flow:E001'),('type','=','in')]) assert len(in_picking_id), "Picking in hasn't been created." in_picking = self.browse(cr, uid, in_picking_id[0]) assert in_picking.move_lines[0].location_id.id == ref('stock.stock_location_intermediatelocation0'), "wrong source location for picking in" assert in_picking.move_lines[0].location_dest_id.id == ref('stock.stock_location_shop0'), "wrong destination location for picking in" assert in_picking.company_id.id == ref('stock.res_company_1'), "wrong company for picking in" out_picking_id = self.search(cr, uid, [('origin','like','%E003%'),('type','=','out')]) assert len(out_picking_id), "Picking out hasn't been created." out_picking = self.browse(cr, uid, out_picking_id[0]) assert out_picking.move_lines[0].location_id.id == ref('stock.stock_location_stock'), "wrong source location for picking out" assert out_picking.move_lines[0].location_dest_id.id == ref('stock.stock_location_intermediatelocation0'), "wrong destination location for picking out" assert out_picking.company_id.id == ref('base.main_company'), "wrong company for picking out"