2 In order to test the procurement with product type buy in OpenERP, I will create product
3 and then I will create procurement for this product.
7 !record {model: product.product, id: product_product_cddrive0}:
8 categ_id: product.product_category_3
12 procure_method: make_to_order
18 uom_id: product.product_uom_unit
19 uom_po_id: product.product_uom_unit
27 name: base.res_partner_asus
31 I create procurement order.
33 !record {model: procurement.order, id: procurement_order_testcase0}:
34 company_id: base.main_company
35 date_planned: !eval time.strftime('%Y-%m-%d %H:%M:%S')
36 location_id: stock.stock_location_stock
39 procure_method: make_to_order
40 product_id: product_product_cddrive0
42 product_uom: product.product_uom_unit
43 product_uos: product.product_uom_unit
47 I confirm on procurement order.
49 !workflow {model: procurement.order, action: button_confirm, ref: procurement_order_testcase0}
53 !function {model: procurement.order, name: run_scheduler}:
54 - model: procurement.order
57 I check that purchase order is generated.
59 !python {model: procurement.order}: |
60 from tools.translate import _
61 proc_ids = self.browse(cr, uid, [ref('procurement_order_testcase0')])[0]
62 assert(proc_ids.purchase_id), _('Purchase Order is not Created!')
64 I check the state is running.
66 !python {model: procurement.order}: |
67 from tools.translate import _
68 proc_ids = self.browse(cr, uid, [ref('procurement_order_testcase0')])[0]
69 assert(proc_ids.state == 'running'), _('Exception')
71 I confirm and Approve the purchase order.
73 !python {model: purchase.order}: |
74 procurement_obj = self.pool.get('procurement.order')
75 proc_ids = procurement_obj.browse(cr, uid, [ref('procurement_order_testcase0')])[0]
77 wf_service = netsvc.LocalService("workflow")
78 wf_service.trg_validate(uid, 'purchase.order',proc_ids.purchase_id.id,'purchase_confirm', cr)
80 I receive the order of the supplier ASUStek from the Incoming Shipments menu.
82 !python {model: stock.picking }: |
84 procurement_obj = self.pool.get('procurement.order')
85 proc_ids = procurement_obj.browse(cr, uid, [ref('procurement_order_testcase0')])[0]
86 picking_ids = self.search(cr, uid, [('purchase_id', '=', proc_ids.purchase_id.id),('type','=','in')])
87 pickings = self.browse(cr, uid, picking_ids)
88 for picking in pickings:
89 move = picking.move_lines[0]
91 'partner_id': picking.address_id.partner_id.id,
92 'address_id': picking.address_id.id,
93 'delivery_date' : time.strftime('%Y-%m-%d')
95 partial_datas['move%s'%(move.id)]= {
96 'product_id': move.product_id,
97 'product_qty': move.product_qty,
98 'product_uom': move.product_uom.id,
100 self.do_partial(cr, uid, [picking.id], partial_datas)
102 I confirm the Reservation.
104 !python {model: stock.move }: |
105 procurement_obj = self.pool.get('procurement.order')
106 proc_ids = procurement_obj.browse(cr, uid, [ref('procurement_order_testcase0')])[0]
107 self.action_done(cr,uid,[proc_ids.move_id.id])
109 I check the state is Done.
111 !python {model: procurement.order}: |
112 from tools.translate import _
113 proc_ids = self.browse(cr, uid, [ref('procurement_order_testcase0')])[0]
114 assert(proc_ids.state == 'done'), _('Order is not in done state')