-
  In order to test project_mrp module with OpenERP I want to create sale orders 
  with product type 'service' so when procurement runs one task is created.
-
  I create record for a service type product.
-
  !record {model: product.product, id: product_product_partnerstraining0}:
    categ_id: product.product_category_7
    cost_method: standard
    mes_type: fixed
    name: Partners Training
    procure_method: make_to_order
    supply_method: produce
    type: service
    uom_id: product.uom_day
    uom_po_id: product.uom_day
    warranty: 0.0
- 
  I create a sale order for product Partners Training which has type 'Service'.
- 
  !record {model: sale.order, id: sale_order_so0}:
    date_order: !eval time.strftime('%Y-%m-%d')
    invoice_quantity: order
    name: TESTSO006
    order_policy: manual
    partner_id: base.res_partner_asus
    partner_invoice_id: base.res_partner_address_tang
    partner_order_id: base.res_partner_address_tang
    partner_shipping_id: base.res_partner_address_tang
    order_line:
      - state: draft
        delay: 7.0
        name: Partners Training
        price_unit: 1.0
        product_id: product_product_partnerstraining0
        product_uom: product.uom_day
        product_uom_qty: 5.0
        type: make_to_order
    picking_policy: direct
    pricelist_id: product.list0
    shop_id: sale.shop
    user_id: base.user_demo
-
  I confirm this sale order.
-
  !workflow {model: sale.order, action: order_confirm, ref: sale_order_so0}
-
  I check the procurements.
-
  !python {model: procurement.order}: |
    orderline_obj = self.pool.get('sale.order.line')
    line_ids = orderline_obj.search(cr, uid, [('order_id','=', ref('sale_order_so0'))])
    orders = orderline_obj.browse(cr, uid, line_ids)
    proc_ids = map(lambda x: x.procurement_id.id, orders)
    assert proc_ids, 'No Procurements!'
-
  The scheduler runs.
-
  !function {model: procurement.order, name: run_scheduler}:
    - model: procurement.order
      search: "[]"
-
  Now I check that one task is created for my sale order.
-
  !python {model: project.task}: |
    order_obj = self.pool.get('sale.order')
    order = order_obj.browse(cr, uid, ref('sale_order_so0')) 
    task_id = self.search(cr, uid, [('name','like', order.name)]) 
    assert task_id, 'No Task is created!'

