[FIX] sale,stock_location: Fixed runbot errors.
[odoo/odoo.git] / addons / sale / test / so_make_invoice.yml
1 -
2   In order to test the 'Make Invoices' wizard of sale module in the Open-ERP,
3   I create two Sale order,group them and create invoice.
4 -
5   I create a Sale Order for Slider Mobile for qty 100 having order_policy manual.
6 -
7   !record {model: sale.order, id: sale_order_so3}:
8     date_order: !eval time.strftime('%Y-%m-%d')
9     invoice_quantity: order
10     name: Test_SO003
11     order_line:
12       - name: Slider Mobile
13         price_unit: 200.0
14         product_uom: product.product_uom_unit
15         product_uom_qty: 100.0
16         state: draft
17         delay: 7.0
18         product_id: sale.product_product_slidermobile0
19         product_uos_qty: 100.0
20         type: make_to_order
21     order_policy: manual
22     partner_id: sale.res_partner_cleartrail0
23     partner_invoice_id: sale.res_partner_address_2
24     partner_order_id: sale.res_partner_address_1
25     partner_shipping_id: sale.res_partner_address_3
26     picking_policy: direct
27     pricelist_id: product.list0
28     shop_id: sale.shop
29 -
30   I confirm the Sale Order.
31 -
32   !workflow {model: sale.order, action: order_confirm, ref: sale_order_so3}
33 -
34   I create a Sale Order for products Slider Mobile and LG Viewty Smart for qty 100 having order_policy manual.
35 -
36   !record {model: sale.order, id: sale_order_so4}:
37     date_order: !eval time.strftime('%Y-%m-%d')
38     invoice_quantity: order
39     name: Test_SO004
40     order_line:
41       - name: Slider Mobile
42         price_unit: 200.0
43         product_uom: product.product_uom_unit
44         product_uom_qty: 100.0
45         state: draft
46         delay: 7.0
47         product_id: sale.product_product_slidermobile0
48         product_uos_qty: 100.0
49         type: make_to_order
50       - name: LG Viewty Smart
51         price_unit: 170.0
52         product_uom: product.product_uom_unit
53         product_uom_qty: 100.0
54         state: draft
55         delay: 7.0
56         product_id: sale.product_product_lgviewtysmart0
57         product_uos_qty: 100.0
58         th_weight: 0.0
59         type: make_to_order
60     order_policy: manual
61     partner_id: sale.res_partner_cleartrail0
62     partner_invoice_id: sale.res_partner_address_2
63     partner_order_id: sale.res_partner_address_1
64     partner_shipping_id: sale.res_partner_address_3
65     picking_policy: direct
66     pricelist_id: product.list0
67     shop_id: sale.shop
68 -
69   I confirm the Sale Order.
70 -
71   !workflow {model: sale.order, action: order_confirm, ref: sale_order_so4}
72 -
73   Then I click on the "Make Invoices" button
74 -
75   !record {model: sale.make.invoice, id: sale_make_invoice_1}:
76     grouped: 1
77     invoice_date: !eval time.strftime('%Y-%m-%d')
78 -
79   Then I click on the "Create Invoices" button of wizard
80 -
81   !python {model: sale.make.invoice}: |
82     self.make_invoices(cr, uid, [ref("sale_make_invoice_1")], {"lang": 'en_US', "search_default_user_id":
83       1, "tz": False, "active_model": 'sale.order', "active_ids": [ref("sale_order_so4"),ref("sale_order_so3")], "active_id":
84       ref("sale_order_so4")})
85 -
86   I verify that an invoice has been created
87 -
88   !python {model: account.invoice}: |
89     inv = self.search(cr, uid, [('origin','=','Test_SO004|Test_SO003|')])
90     assert inv, "Invoices has not been generated"
91 -
92   I verify that an account invoice line with origin 'Test_SO004' is created
93 -
94   !python {model: account.invoice.line}: |
95     sale_order_obj = self.pool.get('sale.order')
96     acc_inv_obj = self.pool.get('account.invoice')
97     inv = acc_inv_obj.search(cr, uid, [('origin','=','Test_SO004|Test_SO003|')])
98     so = sale_order_obj.browse(cr, uid, ref("sale_order_so4"))
99     inv_line = self.search(cr, uid, [('origin','=',so.name),('name','=','Slider Mobile'),('invoice_id','=',inv)])
100     assert inv_line, "Account invoice line has not been created"
101 -
102   I verify that an account invoice line with origin 'Test_SO003' is created
103 -
104   !python {model: account.invoice.line}: |
105     sale_order_obj = self.pool.get('sale.order')
106     acc_inv_obj = self.pool.get('account.invoice')
107     inv = acc_inv_obj.search(cr, uid, [('origin','=','Test_SO004|Test_SO003|')])
108     so = sale_order_obj.browse(cr, uid, ref("sale_order_so3"))
109     inv_line = self.search(cr, uid, [('origin','=',so.name),('name','=','Slider Mobile'),('invoice_id','=',inv)])
110     assert inv_line, "Account invoice line has not been created"
111 -
112   I open the Invoice for the SO.
113 -
114   !python {model: account.invoice}: |
115     import netsvc
116     wf_service = netsvc.LocalService("workflow")
117     inv = self.search(cr, uid, [('origin','=','Test_SO004|Test_SO003|')])
118     for id in inv:
119         wf_service.trg_validate(uid, 'account.invoice',id,'invoice_open', cr)
120 -
121   I assign an analytic journal to the bank journal
122 -
123   !record {model: account.journal, id: sale.account_journal_bankjournal0}:
124     analytic_journal_id: account.cose_journal_sale
125 -
126   I pay the invoice
127 -
128   !python {model: account.invoice}: |
129     sale_order_obj = self.pool.get('sale.order')
130     so = sale_order_obj.browse(cr, uid, ref("sale_order_so3"))
131     invoice_id = self.search(cr, uid, [('origin','=',so.name),('state','=','open')])
132     self.pay_and_reconcile(cr, uid, invoice_id,
133         40000.0, ref('account.cash'), ref('account.period_5'),
134         ref('sale.account_journal_bankjournal0'), ref('account.cash'),
135         ref('account.period_8'), ref('sale.account_journal_bankjournal0'),
136         name='tst')
137 -
138   I verify the invoice is in Paid state
139 -
140   !python {model: account.invoice}: |
141     invoice_id = self.search(cr, uid, [('origin','=','Test_SO004|Test_SO003|'),('state','=','paid')])
142     assert invoice_id, "Invoice for SO is not in done state."