[IMP] Purchase: Remove from tools.translate import _
[odoo/odoo.git] / addons / purchase / test / procurement_buy.yml
1 -
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.
4 -
5   I create  product.
6 -
7   !record {model: product.product, id: product_product_cddrive0}:
8     categ_id: product.product_category_3
9     cost_method: standard
10     mes_type: fixed
11     name: CD drive
12     procure_method: make_to_order
13     supply_method: buy
14     type: product
15     seller_delay: '1'
16     standard_price: 100.0
17     supply_method: buy
18     uom_id: product.product_uom_unit
19     uom_po_id: product.product_uom_unit
20     volume: 0.0
21     warranty: 0.0
22     weight: 0.0
23     weight_net: 0.0
24     seller_delay: '1'
25     seller_ids:
26       - delay: 1
27         name: base.res_partner_asus
28         min_qty: 2.0
29         qty: 5.0
30 -
31   I create  procurement order.
32 -
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
37     name: Test Case
38     priority: '1'
39     procure_method: make_to_order
40     product_id: product_product_cddrive0
41     product_qty: 5.0
42     product_uom: product.product_uom_unit
43     product_uos: product.product_uom_unit
44     product_uos_qty: 0.0
45     state: draft
46 -
47   I confirm on procurement order.
48 -
49   !workflow {model: procurement.order, action: button_confirm, ref: procurement_order_testcase0}
50 -
51   I run the scheduler.
52 -
53   !function {model: procurement.order, name: run_scheduler}:
54     - model: procurement.order
55       search: "[]"
56 -
57   I check that  purchase order is generated.
58 -
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!')
63 -
64   I check the state is running.
65 -
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')
70 -
71   I confirm  and Approve the purchase order.
72 -
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]
76     import netsvc
77     wf_service = netsvc.LocalService("workflow")
78     wf_service.trg_validate(uid, 'purchase.order',proc_ids.purchase_id.id,'purchase_confirm', cr)
79 -
80   I receive the order of the supplier ASUStek from the Incoming Shipments menu.
81 -
82   !python {model: stock.picking }: |
83    import time
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]
90       partial_datas = {
91             'partner_id': picking.address_id.partner_id.id,
92             'address_id': picking.address_id.id,
93             'delivery_date' : time.strftime('%Y-%m-%d')
94            }
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,
99       }
100       self.do_partial(cr, uid, [picking.id], partial_datas)
101 -
102   I confirm the Reservation.
103 -
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])
108 -
109   I check the state is Done.
110 -
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')