2010-10-08 10:58:14 +00:00
-
2013-05-17 14:58:20 +00:00
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.
2011-01-05 05:03:29 +00:00
-
2011-08-04 13:17:05 +00:00
!record {model: product.product, id: product_product_hpcdwriters01}:
2010-10-08 10:58:14 +00:00
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
2013-05-17 14:58:20 +00:00
property_account_expense : account.a_expense
property_account_income : account.rev
2010-10-08 10:58:14 +00:00
flow_pull_ids :
- invoice_state : none
location_id : stock.stock_location_shop0
2013-05-17 14:58:20 +00:00
location_src_id : stock.stock_location_intermediatelocation0
2010-10-08 10:58:14 +00:00
name : E001
2013-05-17 14:58:20 +00:00
picking_type : in
procure_method : make_to_order
2010-10-08 10:58:14 +00:00
type_proc : move
2013-05-13 15:27:17 +00:00
company_id : stock.res_company_1
2010-10-08 10:58:14 +00:00
- invoice_state : none
location_id : stock.stock_location_shop1
2013-05-14 08:10:59 +00:00
location_src_id : stock.stock_location_intermediatelocation0
2010-10-08 10:58:14 +00:00
name : E002
2013-05-17 14:58:20 +00:00
picking_type : in
procure_method : make_to_order
2010-10-08 10:58:14 +00:00
type_proc : move
2013-05-17 14:58:20 +00:00
company_id : stock.res_company_2
2010-10-08 10:58:14 +00:00
- invoice_state : none
2013-05-14 08:10:59 +00:00
location_id : stock.stock_location_intermediatelocation0
2010-10-08 10:58:14 +00:00
location_src_id : stock.stock_location_stock
name : E003
2013-05-14 08:10:59 +00:00
type_proc : move
2013-05-17 14:58:20 +00:00
picking_type : out
2013-05-13 15:27:17 +00:00
company_id : base.main_company
2010-10-08 10:58:14 +00:00
property_stock_inventory : stock.location_inventory
property_stock_procurement : stock.location_procurement
property_stock_production : stock.location_production
qty_available : 15
2011-01-05 05:03:29 +00:00
-
2010-10-13 22:00:42 +00:00
I create a procurement order.
2011-01-05 05:03:29 +00:00
-
2010-10-08 10:58:14 +00:00
!record {model: procurement.order, id: procurement_order_test0}:
2013-05-10 14:15:50 +00:00
company_id : stock.res_company_1
2011-01-05 05:03:29 +00:00
date_planned : !eval time.strftime('%Y-%m-%d %H:%M:%S')
2010-10-08 10:58:14 +00:00
location_id : stock.stock_location_shop0
name : Testing pulled flow
priority : '1'
procure_method : make_to_order
2011-08-04 13:17:05 +00:00
product_id : product_product_hpcdwriters01
2010-10-08 10:58:14 +00:00
product_qty : 5.0
product_uom : product.product_uom_unit
product_uos : product.product_uom_unit
product_uos_qty : 0.0
2011-01-05 05:03:29 +00:00
-
2010-10-13 22:00:42 +00:00
I confirm the procurement order.
2011-01-05 05:03:29 +00:00
-
2010-10-08 10:58:14 +00:00
!workflow {model: procurement.order, action: button_confirm, ref: procurement_order_test0}
2011-01-05 05:03:29 +00:00
-
2010-10-08 10:58:14 +00:00
I launch the scheduler to compute procurement.
2011-01-05 05:03:29 +00:00
-
2010-10-08 10:58:14 +00:00
!python {model: procurement.order.compute.all}: |
proc_obj = self.pool.get('procurement.order')
2013-05-17 14:58:20 +00:00
proc_obj._procure_confirm(cr,uid, ids=[ref('procurement_order_test0')])
2010-10-08 10:58:14 +00:00
-
2010-10-13 22:00:42 +00:00
I check the new procurement order has been created .
2010-10-08 10:58:14 +00:00
-
2011-01-05 05:03:29 +00:00
!python {model: procurement.order }: |
2013-05-17 14:58:20 +00:00
procurement_ids = self.search(cr, uid, [('name','=','E001')])
assert len(procurement_ids), "Procurement order hasn't been created."
2010-10-08 10:58:14 +00:00
-
2013-05-17 14:58:20 +00:00
I check the Outgoing Picking is created for source location Stock and destination Chicago shop.
2010-10-08 10:58:14 +00:00
-
!python {model: stock.picking }: |
2013-05-17 14:58:20 +00:00
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"