[ADD] Sale_margin: YAML
[odoo/odoo.git] / addons / sale_margin / test / sale_margin.yml
1 -
2   In order to test the sale_margin module in OpenERP,
3   I create a sale order and verify its margin
4 -
5    I place a sale order for product keyboard, quantity 50
6 -
7   !record {model: sale.order, id: sale_order_so11}:
8     date_order: '2010-08-04'
9     invoice_quantity: order
10     name: Test_SO011
11     order_line:
12       - name: '[KEYA] Keyboard - AZERTY'
13         price_unit: 7.0
14         product_uom: product.product_uom_unit
15         product_uom_qty: 100.0
16         state: draft
17         delay: 7.0
18         product_id: product.product_product_24
19         product_uos_qty: 100.0
20         th_weight: 0.0
21         type: make_to_stock
22     order_policy: manual
23     partner_id: base.res_partner_4
24     partner_invoice_id: base.res_partner_address_7
25     partner_order_id: base.res_partner_address_7
26     partner_shipping_id: base.res_partner_address_7
27     picking_policy: direct
28     pricelist_id: product.list0
29     shop_id: sale.shop
30 -
31   I confirm the sale order
32 -
33   !workflow {model: sale.order, action: order_confirm, ref: sale_order_so11}
34 -
35   I verify that margin field gets bind with the value
36 -
37   !python {model: sale.order}: |
38     so = self.browse(cr, uid, ref("sale_order_so11"))
39     assert so.margin, "No margin !" 
40 -
41   I verify that the picking has been generated for the sale order
42 -
43   !python {model: sale.order}: |
44     so = self.browse(cr, uid, ref("sale_order_so11"))
45     assert so.picking_ids,"Picking has not been generated"
46 -
47   Then I click on the 'Create Invoice' button of 'Outgoing Orders'
48 -
49   !python {model: stock.picking}: |
50     sale_order_obj = self.pool.get('sale.order')
51     so = sale_order_obj.browse(cr, uid, ref("sale_order_so11"))
52     ids = self.search(cr, uid, [('origin', '=', so.name),('type', '=', 'out')])
53     self.create_invoice(cr, uid, ids, {"lang": "en_US", "search_default_available":
54       1, "tz": False, "active_model": "ir.ui.menu", "contact_display": "partner",
55       "active_ids": [ref("stock.menu_action_picking_tree")], "active_id": ref("stock.menu_action_picking_tree"),
56       })
57 -
58   I verify that an invoice has been generated from picking
59 -
60   !python {model: stock.picking}: |
61     sale_order_obj = self.pool.get('sale.order')
62     so = sale_order_obj.browse(cr, uid, ref("sale_order_so11"))
63     pick_ids = self.search(cr, uid, [('origin', '=', so.name)])
64     pick_brw = self.browse(cr, uid, pick_ids[0])
65     assert pick_brw.invoice_ids,"Invoice has not been created"
66