[IMP] sale:-improvements in the yml file
[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 200 quantity having Shipping Policy 'Invoice from Picking' and Invoice on 'Shipped quantities'
4 -
5   !record {model: sale.order, id: sale_order_so6}:
6     date_order: '2010-07-17'
7     invoice_quantity: order
8     name: Test_SO006BIS
9     order_line:
10       - name: Slider Mobile
11         price_unit: 200
12         product_uom: product.product_uom_unit
13         product_uom_qty: 200.0
14         state: draft
15         delay: 7.0
16         product_id: sale.product_product_slidermobile0
17         product_uos_qty: 200.0
18         type: make_to_order
19     order_policy: picking
20     invoice_quantity: procurement
21     partner_id: sale.res_partner_cleartrail0
22     partner_invoice_id: sale.res_partner_address_2
23     partner_order_id: sale.res_partner_address_1
24     partner_shipping_id: sale.res_partner_address_3
25     picking_policy: direct
26     pricelist_id: product.list0
27     shop_id: sale.shop
28
29   I confirm the Sale Order.
30
31   !workflow {model: sale.order, action: order_confirm, ref: sale_order_so6}
32 -
33   I verify that the picking has been generated for the sale order
34
35   !python {model: sale.order}: |
36     so = self.browse(cr, uid, ref("sale_order_so6"))
37     assert so.picking_ids,"Picking has not been generated for sale_order_so6"
38 -
39   Then I click on the "Product Sent" button of Outgoing Shipments
40 -
41   !record {model: stock.partial.picking, id: stock_partial_picking_0}:
42     date: '2010-07-17 17:52:09'
43 -    
44   I change the quantity on the picking to 199, and confirm partially 100 PCE.
45
46   !python {model: stock.picking }: |
47     import time
48     sale_order_obj = self.pool.get('sale.order')
49     so = sale_order_obj.browse(cr, uid, ref("sale_order_so6"))
50     picking_id = self.search(cr, uid, [('origin','=',so.name),('type','=','out')])
51     if picking_id:
52        pick=self.browse(cr,uid,picking_id[0])
53        self.pool.get('stock.move').write(cr, uid, [pick.move_lines[0].id], {'product_qty': 199, 'product_uos_qty': 199})
54        pick=self.browse(cr,uid,picking_id[0])
55        pick.force_assign(cr, uid)
56        partial_datas = {
57            'partner_id':pick.address_id.partner_id.id,
58            'address_id': pick.address_id.id,
59            'delivery_date' : time.strftime('%Y-%m-%d'),
60        }
61        move = pick.move_lines[0]
62        partial_datas['move%s'%(move.id)]= {
63            'product_id': move.product_id.id,
64            'product_qty': '100',
65            'product_uom': move.product_uom.id,
66        }
67        self.do_partial(cr, uid, [pick.id],partial_datas)
68 -
69   Then I create the invoice from the two partial picking
70
71   !record {model: stock.invoice.onshipping, id: stock_invoice_onshipping_6}:
72     invoice_date: '2010-07-17'
73     journal_id: account.sales_journal
74     type: out_invoice
75 -
76   Then I click on 'Create Invoices' button
77 -
78   !python {model: stock.invoice.onshipping}: |
79     sale_obj = self.pool.get('sale.order')  
80     sale_id = sale_obj.browse(cr, uid, ref("sale_order_so6"))
81     picking_obj = self.pool.get('stock.picking')
82     ids = picking_obj.search(cr, uid, [('origin', '=', sale_id.name)])
83     self.create_invoice(cr, uid, [ref("stock_invoice_onshipping_6")], {"lang": "en_US",
84       "search_default_available": 1, "tz": False, "active_model": "stock.picking",
85       "contact_display": "partner", "active_ids": ids, "active_id": ids[0]})
86 -
87   I verify whether the invoice has been generated for SO
88 -
89   !python {model: sale.order}: |
90     so = self.browse(cr, uid, ref("sale_order_so6"))
91     assert so.invoice_ids, "Invoices has not been generated for sale_order_so6"
92 -
93   I verify that an invoice is created on the basis of shipped quantities 100 not ordered quantities 200
94 -
95   !python {model: account.invoice}: |
96     sale_order_obj = self.pool.get('sale.order')
97     so = sale_order_obj.browse(cr, uid, ref("sale_order_so6"))
98     picking_obj = self.pool.get('stock.picking')
99     ids = picking_obj.search(cr, uid, [('origin', '=', so.name),('type','=','out'),('state','=','done')])
100     qty = qty1 = 0.0
101     for pick_brw in picking_obj.browse(cr,uid, ids):
102         for lines in pick_brw.move_lines:
103             qty=lines.product_qty
104     inv_id = self.search(cr, uid, [('origin', 'like', so.name)])
105     inv_brw = self.browse(cr,uid,inv_id)[0]
106     for inv_lines in inv_brw.invoice_line:
107         qty1=inv_lines.quantity
108     assert (qty1 == qty), "Quantities are not the same"
109 -    
110   I open the Invoice for the SO.
111 -
112   !python {model: account.invoice}: |
113     sale_order_obj = self.pool.get('sale.order')
114     so = sale_order_obj.browse(cr, uid, ref("sale_order_so6"))
115     import netsvc
116     wf_service = netsvc.LocalService("workflow")
117     invoice_ids = so.invoice_ids
118     for invoice in invoice_ids:
119       wf_service.trg_validate(uid, 'account.invoice',invoice.id,'invoice_open', cr)
120 -
121   Assign analytic journal into 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_so6"))
131     invoice_id = self.search(cr, uid, [('origin','like',so.name),('state','=','open')])
132     self.pay_and_reconcile(cr, uid, invoice_id,
133         40000.0, ref('account.cash'), ref('account.period_8'),
134         ref('sale.account_journal_bankjournal0'), ref('account.cash'),
135         ref('account.period_8'), ref('sale.account_journal_bankjournal0'),
136         name='test')
137 -
138   I verify the invoice are in paid state or not. 
139 -
140   !python {model: account.invoice}: |
141     sale_order_obj = self.pool.get('sale.order')
142     so = sale_order_obj.browse(cr, uid, ref("sale_order_so6"))
143     invoice_ids = so.invoice_ids
144     for invoice in invoice_ids:
145         assert invoice.state=='paid', "Invoice for SO is not in done state."
146 -
147   I check that Paid has been set to true.
148 -
149   !python {model: sale.order}: |
150     sale_id=self.browse(cr, uid, ref("sale_order_so6"))
151     assert sale_id.invoiced == True, "Paid has not been set to true"