95191569886086150830682d052258d638e5e369
[odoo/odoo.git] / addons / sale / test / invoice_on_shipped_qty.yml
1 -
2   In order to test the Sale module in OpenERP,
3   I create a Sale Order for Slider Mobile for 500 quantity having Shipping Policy 'Shipping & Manual Invoice' and Invoice on 'Shipped quantities' 
4   in order to create an invoice based on the shipping quantity
5 -
6   !record {model: sale.order, id: sale_order_so6}:
7     date_order: '2010-07-17'
8     invoice_quantity: order
9     name: Test_SO006
10     order_line:
11       - name: Slider Mobile
12         price_unit: 200
13         product_uom: product.product_uom_unit
14         product_uom_qty: 200.0
15         state: draft
16         delay: 7.0
17         product_id: sale.product_product_slidermobile0
18         product_uos_qty: 200.0
19         type: make_to_order
20     order_policy: manual
21     invoice_quantity: procurement
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_so6}
33 -
34   I verify that the picking has been generated for the sale order
35
36   !python {model: sale.order}: |
37     so = self.browse(cr, uid, ref("sale_order_so6"))
38     assert so.picking_ids,"Picking has not been generated for sale_order_so6"
39 -
40   Then I click on the "Products Received" button of Incoming Shipments
41 -
42   !record {model: stock.partial.picking, id: stock_partial_picking_0}:
43     date: '2010-07-17 17:52:09'
44 -    
45   Then I done the picking
46
47   !python {model: stock.picking }: |
48     import time
49     sale_order_obj = self.pool.get('sale.order')
50     so = sale_order_obj.browse(cr, uid, ref("sale_order_so6"))
51     picking_id = self.search(cr, uid, [('origin','=',so.name),('type','=','out')])
52     if picking_id:
53        pick=self.browse(cr,uid,picking_id[0])
54        pick.force_assign(cr, uid)
55        partial_datas = {
56             'partner_id':pick.address_id.partner_id.id,
57              'address_id': pick.address_id.id,
58              'delivery_date' : time.strftime('%Y-%m-%d'),
59             }
60        move = pick.move_lines[0]
61        partial_datas['move%s'%(move.id)]= {
62            'product_id': move.product_id.id,
63            'product_qty': '100',
64            'product_uom': move.product_uom.id,
65        } 
66        self.do_partial(cr, uid, [pick.id],partial_datas)
67 -
68  I click on Create Invoice button to create the invoice.
69
70   !workflow {model: sale.order, action: manual_invoice, ref: sale_order_so6}
71 -
72   I verify whether the invoice has been generated for SO
73 -
74   !python {model: sale.order}: |
75     so = self.browse(cr, uid, ref("sale_order_so6"))
76     assert so.invoice_ids, "Invoices has not been generated for sale_order_so6"
77 -
78  I verify that an invoice is created on the basis of shipped quantity
79 -
80   !python {model: account.invoice}: |
81     sale_order_obj = self.pool.get('sale.order')
82     so = sale_order_obj.browse(cr, uid, ref("sale_order_so6"))
83     picking_obj = self.pool.get('stock.picking')
84     ids = picking_obj.search(cr, uid, [('origin', '=', so.name)])
85     pick_brw = picking_obj.browse(cr,uid, ids)[0]
86     for lines in pick_brw.move_lines:
87         qty=lines.product_qty
88     inv_id = self.search(cr, uid, [('origin', '=', so.name)])
89     inv_brw = self.browse(cr,uid,inv_id)[0]
90     for inv_lines in inv_brw.invoice_line:
91         qty1=inv_lines.quantity
92     invoice_id = self.search(cr, uid, [('qty1','=', 'qty') and ('origin', '=', so.name)])
93     assert invoice_id, "Quantities are not same"
94 -    
95   I open the Invoice for the SO.
96 -
97   !python {model: account.invoice}: |
98     sale_order_obj = self.pool.get('sale.order')
99     so = sale_order_obj.browse(cr, uid, ref("sale_order_so6"))
100     import netsvc
101     wf_service = netsvc.LocalService("workflow")
102     invoice_ids = so.invoice_ids
103     for invoice in invoice_ids:
104       wf_service.trg_validate(uid, 'account.invoice',invoice.id,'invoice_open', cr)
105 -
106   Creating a account invoice pay entry.
107 -
108   !record {model: account.invoice.pay, id: account_invoice_pay_tst1}:
109     amount: 40000.0
110     date: '2010-07-17'
111     journal_id: sale.account_journal_bankjournal0
112     name: tst
113     period_id: account.period_5
114 -
115   I pay the invoice.
116 -
117   !python {model: account.invoice.pay}: |
118     sale_order_obj = self.pool.get('sale.order')
119     so = sale_order_obj.browse(cr, uid, ref("sale_order_so6"))
120     self.wo_check(cr, uid, [ref("account_invoice_pay_tst1")], {"lang": "en_US", "tz":
121       False, "active_model": 'account.invoice', "active_ids": [so.invoice_ids[0].id], "type":
122       "out_invoice", "active_id": so.invoice_ids[0].id, })
123 -
124   Creating an account invoice pay writeoff entry.
125 -
126   !record {model: account.invoice.pay.writeoff, id: account_invoice_pay_writeoff_0}:
127     analytic_id: account.analytic_customers
128     comment: Write-Off
129     writeoff_acc_id: account.a_sale
130     writeoff_journal_id: sale.account_journal_bankjournal0
131 -
132   Pay and Reconcile the Invoice.
133 -
134   !python {model: account.invoice.pay.writeoff}: |
135     sale_order_obj = self.pool.get('sale.order')
136     so = sale_order_obj.browse(cr, uid, ref("sale_order_so6"))
137     self.pay_and_reconcile_writeoff(cr, uid, [ref("account_invoice_pay_writeoff_0")],
138       {"lang": 'en_US', "tz": False, "active_model": 'account.invoice', "active_ids":
139       [so.invoice_ids[0].id], "type": "out_invoice", "active_id": so.invoice_ids[0].id })
140 -
141   I verify the invoice are in paid state or not. 
142 -
143   !python {model: account.invoice}: |
144     sale_order_obj = self.pool.get('sale.order')
145     so = sale_order_obj.browse(cr, uid, ref("sale_order_so6"))
146     invoice_ids = so.invoice_ids
147     for invoice in invoice_ids:
148         assert (invoice.state) =='paid', "Invoice for SO is not in done state."
149 -
150   I check that Paid has been set to true.
151 -
152   !python {model: sale.order}: |
153     sale_id=self.browse(cr, uid, ref("sale_order_so6"))
154     assert(sale_id.invoiced == True), "Paid has not been set to true"