[IMP] Purchase: Remove from tools.translate import _
[odoo/odoo.git] / addons / purchase / test / purchase_from_order.yml
1 -
2   In order to test the purchase flow,I start by creating a new product 'iPod'
3 -
4  !record {model: product.product, id: product_product_ipod0}:
5     categ_id: 'product.product_category_3'
6     cost_method: standard
7     mes_type: fixed
8     name: iPod
9     price_margin: 2.0
10     procure_method: make_to_stock
11     property_stock_inventory: stock.location_inventory
12     property_stock_procurement: stock.location_procurement
13     property_stock_production: stock.location_production
14     seller_delay: '1'
15     standard_price: 100.0
16     supply_method: buy
17     type: product
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 -
25   In order to test the purchase flow,I create a new record where "invoice_method" is From Order.
26 -
27   I create purchase order for iPod.
28 -
29   !record {model: purchase.order, id: purchase_order_po0}:
30     company_id: base.main_company
31     date_order: !eval time.strftime('%Y-%m-%d')
32     invoice_method: order
33     location_id: stock.stock_location_stock
34     order_line:
35       - date_planned: !eval time.strftime('%Y-%m-%d')
36         name: iPod
37         price_unit: 100.0
38         product_id: 'product_product_ipod0'
39         product_qty: 10.0
40         product_uom: product.product_uom_unit
41         state: draft
42     partner_address_id: base.res_partner_address_7
43     partner_id: base.res_partner_4
44     pricelist_id: purchase.list0
45 -
46   Initially purchase order is in the draft state.
47 -
48   !assert {model: purchase.order, id: purchase_order_po0}:
49     - state == 'draft'
50 -
51   I confirm the purchase order for iPod.
52 -
53   !workflow {model: purchase.order, action: purchase_confirm, ref: purchase_order_po0}
54 -
55   I changed Expected Date to Next Day.
56 -
57   !python {model: purchase.order}: |
58     from tools.translate import _
59     from datetime import datetime
60     from dateutil.relativedelta import relativedelta
61     next_day = datetime.today() + relativedelta(days=1)
62     self.write(cr, uid, [ref("purchase_order_po0")], {'minimum_planned_date': next_day})
63 -
64   I check that the order which was initially in the draft state has transit to confirm state.
65 -
66   !assert {model: purchase.order, id: purchase_order_po0}:
67     - state == 'approved'
68 -
69   I check that an entry gets created in the "Lines to Invoice" of Invoice Control on the basis of purchase order line.
70 -
71   !python {model: purchase.order}: |
72     from tools.translate import _
73     pur_order_obj=self.browse(cr, uid, ref("purchase_order_po0"))
74     pur_line=self.pool.get( 'purchase.order.line')
75     search_ids=pur_line.search(cr, uid, [('order_id', '=', pur_order_obj.name) ])
76     assert search_ids, _('Purchase order line is not created!')
77 -
78   To check that wizard "Create Invoices" gets called.
79 -
80   I create purchase order line invoice entry.
81 -
82   !record {model: purchase.order.line_invoice, id: purchase_order_line_invoice_0}:
83     {}
84 -
85   I create invoice for products in the purchase order.
86 -
87   !python {model: purchase.order.line_invoice}: |
88     pur_obj=self.pool.get('purchase.order')
89     ids = []
90     pur_id1=pur_obj.browse(cr, uid, ref("purchase_order_po0"))
91     for line in pur_id1.order_line:
92         ids.append(line.id)
93     self.makeInvoices(cr, uid, [1], context={'active_ids': ids})
94 -
95   I check that invoice gets created.
96 -
97   !python {model: purchase.order}: |
98     from tools.translate import _
99     pur_order_obj=self.browse(cr, uid, ref("purchase_order_po0"))
100     pur_line=self.pool.get( 'purchase.order.line')
101     search_ids=pur_line.search(cr, uid, [('order_id', '=', pur_order_obj.name),('invoiced', '=', '1') ])
102     assert search_ids, _('Invoice is not created!')
103 -
104   I check that a record gets created in the Pending Invoices.
105 -
106   !python {model: purchase.order}: |
107     from tools.translate import _
108     pur_id1=self.browse(cr, uid, ref("purchase_order_po0"))
109     account_obj = self.pool.get('account.invoice')
110     ids = account_obj.search(cr, uid, [('origin', '=', pur_id1.name)])
111     assert ids, _('Pending Invoice is not created!')
112 -
113   I check that the order which was initially in the confirmed state has transit to approved state.
114 -
115   !assert {model: purchase.order, id: purchase_order_po0}:
116     - state == 'approved'
117 -
118   I check that date_approve field of Delivery&Invoices gets bind with the date on which it has been approved.
119 -
120   !python {model: purchase.order}: |
121     pur_id=self.browse(cr, uid, ref("purchase_order_po0"))
122     assert(pur_id.date_approve)
123 -
124   I check that an entry gets created in the pickings.
125 -
126   !python {model: purchase.order}: |
127     pur_id=self.browse(cr, uid, ref("purchase_order_po0"))
128     assert(pur_id.picking_ids)
129 -
130  I check that an entry gets created in the stock moves.
131 -
132   !python {model: purchase.order}: |
133     from tools.translate import _
134     pur_id1=self.browse(cr, uid, ref("purchase_order_po0"))
135     picking_obj = self.pool.get('stock.picking')
136     ids = picking_obj.search(cr, uid, [('origin', '=', pur_id1.name)])
137     pick_id = picking_obj.browse(cr, uid, ids)[0]
138     move_obj = self.pool.get('stock.move')
139     search_id = move_obj.search(cr, uid, [('picking_id', '=', pick_id.name)])
140     assert search_id, _('No Incoming Product!')
141 -
142   I check that Traceability moves are created.
143 -
144   I check that an invoice_ids field of Delivery&Invoices gets bind with the value.
145 -
146   !python {model: purchase.order}: |
147     pur_id2=self.browse(cr, uid, ref("purchase_order_po0"))
148     assert(pur_id2.invoice_ids)