2 In order to test the purchase flow,I start by creating a new product 'iPod'
4 !record {model: product.product, id: product_product_ipod0}:
5 categ_id: 'product.product_category_3'
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
18 uom_id: product.product_uom_unit
19 uom_po_id: product.product_uom_unit
25 In order to test the purchase flow,I create a new record where "invoice_method" is From Order.
27 I create purchase order for iPod.
29 !record {model: purchase.order, id: purchase_order_po0}:
30 company_id: base.main_company
31 date_order: !eval time.strftime('%Y-%m-%d')
33 location_id: stock.stock_location_stock
35 - date_planned: !eval time.strftime('%Y-%m-%d')
38 product_id: 'product_product_ipod0'
40 product_uom: product.product_uom_unit
42 partner_address_id: base.res_partner_address_7
43 partner_id: base.res_partner_4
44 pricelist_id: purchase.list0
46 Initially purchase order is in the draft state.
48 !assert {model: purchase.order, id: purchase_order_po0}:
51 I confirm the purchase order for iPod.
53 !workflow {model: purchase.order, action: purchase_confirm, ref: purchase_order_po0}
55 I changed Expected Date to Next Day.
57 !python {model: purchase.order}: |
58 from tools.translate import _
60 from datetime import datetime
61 from dateutil.relativedelta import relativedelta
62 next_day = datetime.today() + relativedelta(days=1)
63 self._set_minimum_planned_date(cr, uid, ref("purchase_order_po0"), 'minimum_planned_date', next_day.strftime('%Y-%m-%d'),None )
65 I check that the order which was initially in the draft state has transit to confirm state.
67 !assert {model: purchase.order, id: purchase_order_po0}:
70 I check that an entry gets created in the "Lines to Invoice" of Invoice Control on the basis of purchase order line.
72 !python {model: purchase.order}: |
73 from tools.translate import _
74 pur_order_obj=self.browse(cr, uid, ref("purchase_order_po0"))
75 pur_line=self.pool.get( 'purchase.order.line')
76 search_ids=pur_line.search(cr, uid, [('order_id', '=', pur_order_obj.name) ])
77 assert search_ids, _('Purchase order line is not created!')
79 To check that wizard "Create Invoices" gets called.
81 I create purchase order line invoice entry.
83 !record {model: purchase.order.line_invoice, id: purchase_order_line_invoice_0}:
86 I create invoice for products in the purchase order.
88 !python {model: purchase.order.line_invoice}: |
89 pur_obj=self.pool.get('purchase.order')
91 pur_id1=pur_obj.browse(cr, uid, ref("purchase_order_po0"))
92 for line in pur_id1.order_line:
94 self.makeInvoices(cr, uid, [1], context={'active_ids': ids})
96 I check that invoice gets created.
98 !python {model: purchase.order}: |
99 from tools.translate import _
100 pur_order_obj=self.browse(cr, uid, ref("purchase_order_po0"))
101 pur_line=self.pool.get( 'purchase.order.line')
102 search_ids=pur_line.search(cr, uid, [('order_id', '=', pur_order_obj.name),('invoiced', '=', '1') ])
103 assert search_ids, _('Invoice is not created!')
105 I check that a record gets created in the Pending Invoices.
107 !python {model: purchase.order}: |
108 from tools.translate import _
109 pur_id1=self.browse(cr, uid, ref("purchase_order_po0"))
110 account_obj = self.pool.get('account.invoice')
111 ids = account_obj.search(cr, uid, [('origin', '=', pur_id1.name)])
112 assert ids, _('Pending Invoice is not created!')
114 I check that the order which was initially in the confirmed state has transit to approved state.
116 !assert {model: purchase.order, id: purchase_order_po0}:
117 - state == 'approved'
119 I check that date_approve field of Delivery&Invoices gets bind with the date on which it has been approved.
121 !python {model: purchase.order}: |
122 pur_id=self.browse(cr, uid, ref("purchase_order_po0"))
123 assert(pur_id.date_approve)
125 I check that an entry gets created in the pickings.
127 !python {model: purchase.order}: |
128 pur_id=self.browse(cr, uid, ref("purchase_order_po0"))
129 assert(pur_id.picking_ids)
131 I check that an entry gets created in the stock moves.
133 !python {model: purchase.order}: |
134 from tools.translate import _
135 pur_id1=self.browse(cr, uid, ref("purchase_order_po0"))
136 picking_obj = self.pool.get('stock.picking')
137 ids = picking_obj.search(cr, uid, [('origin', '=', pur_id1.name)])
138 pick_id = picking_obj.browse(cr, uid, ids)[0]
139 move_obj = self.pool.get('stock.move')
140 search_id = move_obj.search(cr, uid, [('picking_id', '=', pick_id.name)])
141 assert search_id, _('No Incoming Product!')
143 I check that Traceability moves are created.
145 I check that an invoice_ids field of Delivery&Invoices gets bind with the value.
147 !python {model: purchase.order}: |
148 pur_id2=self.browse(cr, uid, ref("purchase_order_po0"))
149 assert(pur_id2.invoice_ids)