[IMP] sale:-added and modified the yaml files
[odoo/odoo.git] / addons / sale / test / shipping_manual_sale_order.yml
1 -
2   In order to test the sale module, I need to configure details regarding product & customer.
3 -
4   I am going to sell my Mobile products to the customer with name Cleartrail
5
6   I create View Account Type.
7
8   !record {model: account.account.type, id: account_account_type_view0}:
9     close_method: none
10     code: View
11     name: View
12     sign: 1
13
14   I create Income Account Type.
15
16   !record {model: account.account.type, id: account_account_type_income0}:
17     close_method: unreconciled
18     code: Income
19     name: Income
20     sign: 1
21
22   I create Expense Account Type.
23
24   !record {model: account.account.type, id: account_account_type_expense0}:
25     close_method: unreconciled
26     code: Expense
27     name: Expense
28     sign: 1
29
30   I create Cash Account Type.
31
32   !record {model: account.account.type, id: account_account_type_cash0}:
33     close_method: balance
34     code: Cash
35     name: Cash
36     sign: 1
37
38   I create Minimal Chart Account.
39
40   !record {model: account.account, id: account_account_minimalchart0}:
41     code: '0'
42     company_id: base.main_company
43     currency_mode: current
44     name: Minimal Chart
45     parent_left: 1
46     parent_right: 12
47     type: view
48     user_type: account_account_type_view0
49
50   I create Payable Account.
51
52   !record {model: account.account, id: account_account_payable1}:
53     code: AP
54     company_id: base.main_company
55     currency_mode: current
56     name: Payable
57     parent_id: account_account_minimalchart0
58     parent_left: 2
59     parent_right: 3
60     reconcile: true
61     type: payable
62     user_type: account_account_type_expense0
63
64   I create Receivable Account.
65
66   !record {model: account.account, id: account_account_receivable0}:
67     code: AR
68     company_id: base.main_company
69     currency_mode: current
70     name: Receivable
71     parent_id: account_account_minimalchart0
72     parent_left: 4
73     parent_right: 5
74     reconcile: true
75     type: receivable
76     user_type: account_account_type_income0
77
78   I create Cash Account.
79
80   !record {model: account.account, id: account_account_cash0}:
81     code: C
82     company_id: base.main_company
83     currency_mode: current
84     name: Cash
85     parent_id: account_account_minimalchart0
86     parent_left: 6
87     parent_right: 7
88     type: other
89     user_type: account_account_type_cash0
90
91   I create Purchases Account.
92
93   !record {model: account.account, id: account_account_purchases0}:
94     code: P
95     company_id: base.main_company
96     currency_mode: current
97     name: Purchases
98     parent_id: account_account_minimalchart0
99     parent_left: 8
100     parent_right: 9
101     type: other
102     user_type: account_account_type_expense0
103
104   I create Sales Account.
105
106   !record {model: account.account, id: account_account_sales0}:
107     code: S
108     company_id: base.main_company
109     currency_mode: current
110     name: Sales
111     parent_id: account_account_minimalchart0
112     parent_left: 10
113     parent_right: 11
114     type: other
115     user_type: account_account_type_income0
116
117   I create Purchase Journal.
118
119   !record {model: account.journal, id: account_journal_purchasejournal0}:
120     code: PUJ
121     company_id: base.main_company
122     default_credit_account_id: account_account_purchases0
123     default_debit_account_id: account_account_purchases0
124     name: Purchase Journal
125     sequence_id: account.sequence_purchase_journal
126     type: purchase
127     view_id: account.account_journal_view
128
129   I create Sale Journal.
130
131   !record {model: account.journal, id: account_journal_salejournal0}:
132     code: SAJ
133     company_id: base.main_company
134     default_credit_account_id: account_account_sales0
135     default_debit_account_id: account_account_sales0
136     name: Sale Journal
137     sequence_id: account.sequence_sale_journal
138     type: sale
139     view_id: account.account_journal_view
140
141   I create Bank Journal.
142
143   !record {model: account.journal, id: account_journal_bankjournal0}:
144     code: BNK
145     company_id: base.main_company
146     default_credit_account_id: account_account_cash0
147     default_debit_account_id: account_account_cash0
148     name: Bank Journal
149     sequence_id: account.sequence_journal
150     type: cash
151     view_id: account.account_journal_bank_view
152
153   I create ir.property for account payable.
154
155   !record {model: ir.property, id: ir_property_propertyaccountexpensecateg0}:
156     company_id: base.main_company
157     fields_id: account.field_res_partner_property_account_payable
158     name: property_account_expense_categ
159     value_reference: account.account,5
160
161   I create ir.property for account receivable.
162
163   !record {model: ir.property, id: ir_property_propertyaccountincomecateg0}:
164     company_id: base.main_company
165     fields_id: account.field_res_partner_property_account_receivable
166     name: property_account_income_categ
167     value_reference: account.account,6
168
169   I create Partner category Customers.
170
171   !record {model: res.partner.category, id: res_partner_category_customers0}:
172     name: Customers
173 -
174   I create Cleartrail Customer.
175
176   !record {model: res.partner, id: res_partner_cleartrail0}:
177     category_id:
178       - res_partner_category_customers0
179     name: Cleartrail
180
181   I create contact address for Cleartrail.
182
183   !record {model: res.partner.address, id: res_partner_address_1}:
184     partner_id: res_partner_cleartrail0
185     street: onam plaza, 14 B palasia A B Road
186     type: contact
187
188   I create invoice address for Cleartrail.
189
190   !record {model: res.partner.address, id: res_partner_address_2}:
191     partner_id: res_partner_cleartrail0
192     street: sarda house 24 B palasia, A B Road
193     type: invoice
194
195   I create delivery address for Cleartrail.
196
197   !record {model: res.partner.address, id: res_partner_address_3}:
198     partner_id: res_partner_cleartrail0
199     street: sangam house 15 B palasia, A B Road
200     type: delivery
201 -
202   Customer Cleartrail has specific instrument requirement regarding the stockable products.
203
204   I define product category Mobile Products Sellable.
205
206   !record {model: product.category, id: product_category_allproductssellable0}:
207     name: Mobile Products Sellable
208
209   I define product category Mobile Services. 
210
211   !record {model: product.category, id: product_category_services0}:
212     name: Mobile Services
213
214   I define New Chocolate Slider Mobile template.
215
216   !record {model: product.template, id: product_template_newchocolateslidermobile0}:
217     categ_id: product_category_allproductssellable0
218     cost_method: standard
219     list_price: 200.0
220     mes_type: fixed
221     name: New Chocolate Slider Mobile
222     procure_method: make_to_order
223     standard_price: 189.0
224     supply_method: buy
225     type: product
226     uom_id: product.product_uom_unit
227     uom_po_id: product.product_uom_unit
228
229   I define New Chocolate Slider Mobile.
230
231   !record {model: product.product, id: product_product_newchocolateslidermobile0}:
232     categ_id: product_category_allproductssellable0
233     cost_method: standard
234     list_price: 200.0
235     mes_type: fixed
236     name: New Chocolate Slider Mobile
237     pricelist_purchase: 'Default Purchase Pricelist (0.00) : 189.00\n'
238     pricelist_sale: 'Public Pricelist (0.00) : 200.00\n'
239     procure_method: make_to_order
240     property_account_expense: sale.account_account_payable1
241     property_account_income: sale.account_account_receivable0
242     seller_delay: '1'
243     seller_ids:
244       - delay: 1
245         name: base.res_partner_agrolait
246         qty: 5.0
247     standard_price: 189.0
248     supply_method: buy
249     type: product
250     uom_id: product.product_uom_unit
251     uom_po_id: product.product_uom_unit
252
253   I create a Sale Order for New Chocolate Slider Mobile for qty 500 having Shipping Policy is 'Shipping & Manual Invoice'
254 -
255   !record {model: sale.order, id: sale_order_so0}:
256     date_order: '2010-05-12'
257     invoice_quantity: order
258     name: Test_SO002
259     order_line:
260       - name: New Chocolate Slider Mobile
261         price_unit: 200.0
262         product_uom: product.product_uom_unit
263         product_uom_qty: 500.0
264         state: draft
265         delay: 7.0
266         product_id: sale.product_product_newchocolateslidermobile0
267         product_uos_qty: 500.0
268         type: make_to_order
269     order_policy: manual
270     partner_id: sale.res_partner_cleartrail0
271     partner_invoice_id: sale.res_partner_address_2
272     partner_order_id: sale.res_partner_address_1
273     partner_shipping_id: sale.res_partner_address_3
274     picking_policy: direct
275     pricelist_id: product.list0
276     shop_id: sale.shop
277
278   I confirm the Sale Order.
279
280   !workflow {model: sale.order, action: order_confirm, ref: sale_order_so0}
281 -
282   I click on Create Invoice button to create the invoice.
283
284   !workflow {model: sale.order, action: manual_invoice, ref: sale_order_so0}
285 -
286   I verify whether the invoice has been generated for SO
287 -
288   !python {model: sale.order}: |
289     so = self.browse(cr, uid, ref("sale_order_so0"))
290     assert so.invoice_ids, "Invoices has not been generated for sale_order_so0"
291
292   I open the Invoice for the SO.
293
294   !python {model: account.invoice}: |
295     sale_order_obj = self.pool.get('sale.order')
296     so = sale_order_obj.browse(cr, uid, ref("sale_order_so0"))
297     import netsvc
298     wf_service = netsvc.LocalService("workflow")  
299     invoice_ids = so.invoice_ids
300     for invoice in invoice_ids:
301       wf_service.trg_validate(uid, 'account.invoice',invoice.id,'invoice_open', cr) 
302 -
303   Creating a account invoice pay entry.
304
305   !record {model: account.invoice.pay, id: account_invoice_pay_tst0}:
306     amount: 100000.0
307     date: '2010-05-10'
308     journal_id: sale.account_journal_bankjournal0
309     name: test
310     period_id: account.period_5
311
312   I pay the invoice.
313
314   !python {model: account.invoice.pay}: |
315     sale_order_obj = self.pool.get('sale.order')
316     so = sale_order_obj.browse(cr, uid, ref("sale_order_so0"))  
317     self.wo_check(cr, uid, [ref("account_invoice_pay_tst0")], {"lang": "en_US", "tz":
318       False, "active_model": 'account.invoice', "active_ids": [so.invoice_ids[0].id], "type":
319       "out_invoice", "active_id": so.invoice_ids[0].id})
320
321   Creating an account invoice pay writeoff entry.
322
323   !record {model: account.invoice.pay.writeoff, id: account_invoice_pay_writeoff_0}:
324     analytic_id: account.analytic_customers
325     comment: Write-Off
326     writeoff_acc_id: account.a_sale
327     writeoff_journal_id: sale.account_journal_bankjournal0
328
329   Pay and Reconcile the Invoice.
330
331   !python {model: account.invoice.pay.writeoff}: |
332     sale_order_obj = self.pool.get('sale.order')
333     so = sale_order_obj.browse(cr, uid, ref("sale_order_so0"))   
334     self.pay_and_reconcile_writeoff(cr, uid, [ref("account_invoice_pay_writeoff_0")],
335       {"lang": 'en_US', "tz": False, "active_model": 'account.invoice', "active_ids":
336       [so.invoice_ids[0].id], "type": "out_invoice", "active_id": so.invoice_ids[0].id, })
337 -
338   I verify the invoice are in paid state or not. 
339 -
340   !python {model: account.invoice}: |
341     sale_order_obj = self.pool.get('sale.order')
342     so = sale_order_obj.browse(cr, uid, ref("sale_order_so0"))
343     invoice_ids = so.invoice_ids
344     for invoice in invoice_ids:
345         assert (invoice.state) =='paid', "Invoice for SO is not in done state."
346 -
347   I verify that Paid has been set to true.
348 -
349   !python {model: sale.order}: |
350     sale_id=self.browse(cr, uid, ref("sale_order_so0"))
351     assert(sale_id.invoiced == True), "Paid has not been set to true"
352 -   
353   I verify that the picking has been generated for the sale order
354
355   !python {model: sale.order}: |
356     so = self.browse(cr, uid, ref("sale_order_so0"))
357     assert so.picking_ids,"Picking has not been generated for sale_order_so0"
358 -
359   Products are delivered to the Cleartrail Customer.
360
361   !python {model: stock.picking }: |
362    import time
363    sale_order_obj = self.pool.get('sale.order')
364    so = sale_order_obj.browse(cr, uid, ref("sale_order_so0"))
365    picking_id = self.search(cr, uid, [('origin','=',so.name),('type','=','out')])
366    if picking_id:
367       pick=self.browse(cr,uid,picking_id[0])
368       pick.force_assign(cr, uid)
369       partial_datas = {
370            'partner_id':pick.address_id.partner_id.id,
371             'address_id': pick.address_id.id,
372             'delivery_date' : time.strftime('%Y-%m-%d'),
373            }
374       move = pick.move_lines[0]
375       partial_datas['move%s'%(move.id)]= {
376           'product_id': move.product_id.id,
377           'product_qty': move.product_qty,
378           'product_uom': move.product_uom.id,
379       } 
380       self.do_partial(cr, uid, [pick.id],partial_datas)
381 -
382   I verify that picking order is in done state.
383 -
384   !python {model: stock.picking }: |
385    sale_order_obj = self.pool.get('sale.order')
386    so = sale_order_obj.browse(cr, uid, ref("sale_order_so0"))
387    picking_id = self.search(cr, uid, [('origin','=',so.name),('type','=','out')])
388    if picking_id:
389      pick = self.browse(cr,uid,picking_id[0])
390      assert (pick.state) =='done', "Picking for SO is not in done state." 
391 -
392   I verify that a procurement has been generated for so
393 -
394   !python {model: procurement.order}: |
395     from tools.translate import _
396     sale_order_obj = self.pool.get('sale.order')
397     so = sale_order_obj.browse(cr, uid, ref("sale_order_so0"))
398     proc_ids = self.search(cr, uid, [('origin','=',so.name)])
399     assert proc_ids, _('No Procurements!')
400 -
401   Then I click on the "Run Procurement" button
402 -
403   !python {model: procurement.order}: |
404     sale_order_obj = self.pool.get('sale.order')
405     so = sale_order_obj.browse(cr, uid, ref("sale_order_so0"))
406     import netsvc
407     wf_service = netsvc.LocalService("workflow")
408     proc_ids = self.search(cr, uid, [('origin','=',so.name)])
409     for proc in proc_ids:
410       wf_service.trg_validate(uid, 'procurement.order',proc,'button_check', cr)
411 -
412   I verify that a procurement state is "running"
413 -
414   !python {model: procurement.order}: |
415     from tools.translate import _
416     sale_order_obj = self.pool.get('sale.order')
417     so = sale_order_obj.browse(cr, uid, ref("sale_order_so0"))
418     proc_ids = self.search(cr, uid, [('origin','=',so.name) and ('state','=','running')])
419     assert proc_ids, _('Procurement is not in the running state!')
420 -
421   I verify that a purchase order has been generated
422 -
423   !python {model: purchase.order}: |
424     from tools.translate import _
425     sale_order_obj = self.pool.get('sale.order')
426     so = sale_order_obj.browse(cr, uid, ref("sale_order_so0"))
427     proc_ids = self.search(cr, uid, [('origin','=',so.name)])
428     assert proc_ids, _('Purchase order has not been generated')
429 -
430   I click on the "Confirm" button to confirm the purchase order
431 -
432   !python {model: purchase.order}: |
433     sale_order_obj = self.pool.get('sale.order')
434     so = sale_order_obj.browse(cr, uid, ref("sale_order_so0"))
435     import netsvc
436     wf_service = netsvc.LocalService("workflow")
437     pur_ids = self.search(cr, uid, [('origin','=',so.name)])
438     for pur in pur_ids:
439       wf_service.trg_validate(uid, 'purchase.order',pur,'purchase_confirm', cr)
440
441   I click on the "Approved by supplier" button to approve the purchase order
442 -
443   !python {model: purchase.order}: |
444     sale_order_obj = self.pool.get('sale.order')
445     so = sale_order_obj.browse(cr, uid, ref("sale_order_so0"))
446     import netsvc
447     wf_service = netsvc.LocalService("workflow")
448     pur_ids = self.search(cr, uid, [('origin','=',so.name)])
449     for pur in pur_ids:
450       wf_service.trg_validate(uid, 'purchase.order',pur,'purchase_approve', cr)
451 -
452   I verify that a picking related to purchase order has been generated. 
453 -
454   !python {model: purchase.order}: |
455     sale_order_obj = self.pool.get('sale.order')
456     so = sale_order_obj.browse(cr, uid, ref("sale_order_so0"))
457     ids = self.search(cr, uid, [('origin','=',so.name)])
458     po = self.browse(cr, uid, ids)[0]
459     assert(po.picking_ids)
460 -  
461   Then I click on the "Products Received" button of Incoming Shipments
462 -
463   !record {model: stock.partial.picking, id: stock_partial_picking_0}:
464     date: '2010-07-13 17:52:09'
465 -
466   I click on the "Validate" button
467 -
468   !python {model: stock.picking}: |
469     sale_order_obj = self.pool.get('sale.order')
470     pur_obj = self.pool.get('purchase.order')
471     so = sale_order_obj.browse(cr, uid, ref("sale_order_so0"))
472     pur_id = pur_obj.search(cr, uid, [('origin','=',so.name)])
473     po = pur_obj.browse(cr, uid, pur_id)[0]
474     pick_ser_id = self.search(cr, uid, [('purchase_id', '=', po.id )])
475     import netsvc
476     wf_service = netsvc.LocalService("workflow")
477     for pick in pick_ser_id:
478       wf_service.trg_validate(uid, 'stock.picking',pick,'button_done', cr)
479 -
480   I verify that picking state is done
481 -
482   !python {model: purchase.order}: |
483     from tools.translate import _
484     sale_order_obj = self.pool.get('sale.order')
485     so = sale_order_obj.browse(cr, uid, ref("sale_order_so0"))
486     pur_id = self.search(cr, uid, [('origin','=',so.name)])
487     po = self.browse(cr, uid, pur_id)[0]
488     picking_obj = self.pool.get('stock.picking')
489     ids = picking_obj.search(cr, uid, [('purchase_id', '=', po.id ) and ('state', '=', 'done')])
490     assert ids, _('Picking is not in the done state!')
491 -
492   I verify that a "Picked" has been set to true 
493 -
494   !python {model: sale.order}: |
495     so = self.browse(cr, uid, ref("sale_order_so0"))
496     assert (so.shipped == True), "Picking is not done."
497 -  
498   I verify that a sale order is in done state
499 -
500    !python {model: sale.order}: |
501     so = self.browse(cr, uid, ref("sale_order_so0"))
502     assert (so.state == 'done'), "Sale order is not in the done state."
503