[FIX] sale,stock_location: Fixed runbot errors.
[odoo/odoo.git] / addons / sale / test / sale_procurement.yml
1 -
2   In order to test the sale order working with procurements I will create some
3   products with different supply method and procurement method.
4 -
5   I create one product Table as MTO.
6 -
7   !record {model: product.product, id: product_product_table0}:
8     categ_id: product.cat1
9     name: Table
10     procure_method: make_to_order
11     supply_method: produce
12     type: product
13     uom_id: product.product_uom_unit
14     uom_po_id: product.product_uom_unit
15 -
16   I create another product Wood as MTS.
17 -
18   !record {model: product.product, id: product_product_wood0}:
19     categ_id: product.cat1
20     name: Wood
21     procure_method: make_to_stock
22     supply_method: buy
23     type: product
24     uom_id: product.product_uom_kgm
25     uom_po_id: product.product_uom_kgm
26 -
27   I define Minimum stock rule for my stockable product Wood (qty between 10 and 15)
28 -
29   !record {model: stock.warehouse.orderpoint, id: stock_warehouse_orderpoint_op0}:
30     company_id: base.main_company
31     location_id: stock.stock_location_stock
32     logic: max
33     product_id: product_product_wood0
34     product_max_qty: 15.0
35     product_min_qty: 10.0
36     product_uom: product.product_uom_kgm
37     qty_multiple: 1
38     warehouse_id: stock.warehouse0
39 -
40   Now I make a sale order for table.
41 -
42   !record {model: sale.order, id: sale_order_so3}:
43     amount_total: 5.0
44     amount_untaxed: 5.0
45     date_order: !eval time.strftime('%Y-%m-%d')
46     invoice_quantity: order
47     order_line:
48       - company_id: base.main_company
49         delay: 7.0
50         name: Table
51         price_unit: 1.0
52         product_id: product_product_table0
53         product_uom: product.product_uom_unit
54         product_uom_qty: 5.0
55         product_uos_qty: 5.0
56         state: draft
57         type: make_to_order
58     order_policy: manual
59     partner_id: base.res_partner_agrolait
60     partner_invoice_id: base.res_partner_address_8
61     partner_order_id: base.res_partner_address_8
62     partner_shipping_id: base.res_partner_address_8
63     picking_policy: direct
64     pricelist_id: product.list0
65     shop_id: sale.shop
66 -
67   I confirm the order.
68 -
69   !workflow {model: sale.order, action: order_confirm, ref: sale_order_so3}
70 -
71   I check that procurement is generated.
72 -
73   !python {model: procurement.order}: |
74     from tools.translate import _
75     sale_order_obj = self.pool.get('sale.order')
76     so = sale_order_obj.browse(cr, uid, ref("sale_order_so3"))
77     proc_ids = self.search(cr, uid, [('origin','=',so.name)])
78     assert proc_ids, _('No Procurements!')
79 -
80   I run the scheduler.
81 -
82   !function {model: procurement.order, name: run_scheduler}:
83     - model: procurement.order
84       search: "[('state','=','confirmed')]"
85 -
86   I check that the procurement for the product table is in exception state.
87   As my product's supply method is produce and the BoM is not defined.
88 -
89   !python {model: procurement.order}: |
90     from tools.translate import _
91     proc_ids = self.search(cr, uid, [('state','=','exception'),('product_id','=',ref('sale.product_product_table0'))])
92     assert not proc_ids, _('There is no procurement in exception state!')