[REV] stock: revert of f229d40fb7a2a16c6f211a059694b18124b9719a
[odoo/odoo.git] / addons / sale_mrp / test / sale_mrp.yml
1 -
2   In order to test the sale_mrp module in OpenERP, I start by creating a new product 'Slider Mobile'
3 -
4   I define product category Mobile Products Sellable.
5 -
6   !record {model: product.category, id: product_category_allproductssellable0}:
7     name: Mobile Products Sellable
8 -
9   I define product category Mobile Services.
10 -
11   !record {model: product.category, id: product_category_16}:
12     name: Mobile Services
13 -
14   I define product template for Slider Mobile.
15 -
16   !record {model: product.template, id: product_template_slidermobile0}:
17     categ_id: product_category_allproductssellable0
18     list_price: 200.0
19     mes_type: fixed
20     name: Slider Mobile
21     standard_price: 189.0
22     type: product
23     uom_id: product.product_uom_unit
24     uom_po_id: product.product_uom_unit
25 -
26   I define a product Slider Mobile
27 -
28   !record {model: product.product, id:  product_product_slidermobile0}:
29     categ_id: product_category_allproductssellable0
30     list_price: 200.0
31     mes_type: fixed
32     name: Slider Mobile
33     seller_delay: '1'
34     seller_ids:
35       - delay: 1
36         name: base.res_partner_2
37         min_qty: 2.0
38         qty: 5.0
39     standard_price: 189.0
40     type: product
41     uom_id: product.product_uom_unit
42     uom_po_id: product.product_uom_unit
43
44   I add the routes manufacture and mto to the product
45
46   !python {model: product.product}: |
47     route_warehouse0_manufacture = self.pool.get('stock.warehouse').browse(cr, uid, ref('stock.warehouse0')).manufacture_pull_id.route_id.id 
48     route_warehouse0_mto = self.pool.get('stock.warehouse').browse(cr, uid, ref('stock.warehouse0')).mto_pull_id.route_id.id 
49     self.write(cr, uid, ref('product_product_slidermobile0'), { 'route_ids': [(6, 0, [route_warehouse0_mto,route_warehouse0_manufacture])]}, context=context)
50 -
51   I create a Bill of Material record for Slider Mobile
52 -
53   !record {model: mrp.bom, id: mrp_bom_slidermobile0}:
54     company_id: base.main_company
55     name: Slider Mobile
56     product_efficiency: 1.0
57     product_tmpl_id: product_product_slidermobile0_product_template
58     product_id: product_product_slidermobile0
59     product_qty: 1.0
60     product_uom: product.product_uom_unit
61     sequence: 0.0
62     type: normal
63 -
64   I create a sale order for product Slider mobile
65 -
66   !record {model: sale.order, id: sale_order_so0}:
67     client_order_ref: ref1
68     date_order: !eval time.strftime('%Y-%m-%d')
69     name: Test_SO001
70     order_line:
71       - name: Slider Mobile
72         price_unit: 200
73         product_uom: product.product_uom_unit
74         product_uom_qty: 500.0
75         state: draft
76         delay: 7.0
77         product_id: product_product_slidermobile0
78         product_uos_qty: 500.0
79     order_policy: manual
80     partner_id: base.res_partner_4
81     partner_invoice_id: base.res_partner_address_7
82     partner_shipping_id: base.res_partner_address_7
83     picking_policy: direct
84     pricelist_id: product.list0
85 -
86   I confirm the sale order
87 -
88   !workflow {model: sale.order, action: order_confirm, ref: sale_order_so0}
89 -
90   I verify that a procurement has been generated for sale order
91 -
92   !python {model: procurement.order}: |
93     sale_order_obj = self.pool.get('sale.order')
94     so = sale_order_obj.browse(cr, uid, ref("sale_order_so0"))
95     proc_ids = self.search(cr, uid, [('origin','=',so.name)])
96     assert proc_ids, 'No Procurements!'
97 -
98   Then I click on the "Run Procurement" button
99 -
100   !python {model: procurement.order}: |
101     sale_order_obj = self.pool.get('sale.order')
102     so = sale_order_obj.browse(cr, uid, ref("sale_order_so0"))
103     proc_ids = self.search(cr, uid, [('origin','like',so.name)])
104     self.run(cr, uid, proc_ids)
105 -
106   I verify that a procurement state is "running"
107 -
108   !python {model: procurement.order}: |
109     sale_order_obj = self.pool.get('sale.order')
110     so = sale_order_obj.browse(cr, uid, ref("sale_order_so0"))
111     proc_ids = self.search(cr, uid, [('origin','like',so.name)])
112     # Check that all procurement are running
113     for procu in self.browse(cr,uid,proc_ids,context=context):        
114         assert procu.state == u'running', 'Procurement with id %d should be with a state "running" but is with a state : %s!' %(procu.id,procu.state)
115 -
116   I verify that a manufacturing order has been generated, and that its name and reference are correct
117 -
118   !python {model: sale.order}: |
119     mnf_obj = self.pool.get('mrp.production')
120     so = self.browse(cr, uid, ref("sale_order_so0"))
121     mnf_id = mnf_obj.search(cr, uid, [('origin','like',so.name)])
122     assert mnf_id, 'Manufacturing order has not been generated'
123     mo = mnf_obj.browse(cr, uid, mnf_id)[0]
124     assert mo.sale_name == so.name, 'Wrong Name for the Manufacturing Order. Expected %s, Got %s' % (so.name, mo.name)
125     assert mo.sale_ref == so.client_order_ref, 'Wrong Sale Reference for the Manufacturing Order'