-
  In order to test the manufacturing order working with procurements I will use
  some products with different supply method and procurement method, also check 
  the bills of material for the products.
-
  I am creating one manufacturing order.
- 
  !record {model: mrp.production, id: mrp_production_mo1}:
    company_id: base.main_company
    date_planned: '2010-05-06 14:55:52'
    location_dest_id: stock.stock_location_stock
    location_src_id: stock.stock_location_stock
    product_id: product.product_product_pc1
    product_qty: 5.0
    product_uom: product.product_uom_unit
    product_uos_qty: 0.0
-
  I compute the data.
-
  !python {model: mrp.production}: |
    self.action_compute(cr, uid, [ref("mrp_production_mo1")], {"lang": "en_US", "tz":
      False, "search_default_current": 1, "active_model": "ir.ui.menu", "active_ids":
      [ref("mrp.menu_mrp_production_action")], "active_id": ref("mrp.menu_mrp_production_action"),
      })
-
  I confirm the order.
- 
  !workflow {model: mrp.production, action: button_confirm, ref: mrp_production_mo1}
-
  I am checking Procurement orders for components of PC1. 
-
  !python {model: procurement.order}: |
    from tools.translate import _
    production_obj = self.pool.get('mrp.production')
    production = production_obj.browse(cr, uid, ref('mrp_production_mo1'))
    product_ids = map(lambda x:x.product_id.id, production.move_lines)
    proc_ids = self.search(cr, uid, [('product_id','in',product_ids)])
    assert proc_ids, _('No Procurements!')
-
  The scheduler runs.
-
  !function {model: procurement.order, name: run_scheduler}:
    - model: procurement.order
      search: "[]"
-
  I am checking Internal picking.
-
  !python {model: stock.picking}: |
    from tools.translate import _
    pick_ids = self.search(cr, uid, [('type','=','internal')])
    assert pick_ids, _('No Internal Pickings!')
-
  I see that there is a manufacturing order for the sub product of PC1 with ready state.
-
  !python {model: mrp.production}: |
    from tools.translate import _
    order_ids = self.search(cr, uid, [('state','=','ready')])
    assert order_ids, _('No manufacturing order in Ready state!')
-
  I start producing that product first. So I marked it as started.
-
  !workflow {model: mrp.production, action: button_produce, ref: mrp_production_mo1}
-
  I create record for producing products with quantity 5.00.
-
  !record {model: mrp.product.produce, id: mrp_product_produce0}:
    product_qty: 5.00
    mode: 'consume_produce'
-
  I produce the product.
-
  !python {model: mrp.product.produce}: |
    prod_obj = self.pool.get('mrp.production')
    prod_ids = prod_obj.search(cr, uid, [('state','=','confirmed')])
    self.do_produce(cr, uid, [ref('mrp_product_produce0')], context={'active_ids': prod_ids})
-
  Now the manufacturing order for subproduct CPU_GEN is done and manufacturing
  order for PC1 is in ready state.
-
  !python {model: mrp.production}: |
    from tools.translate import _
    prod_ids = self.search(cr, uid, [('state','=','done')])
    assert prod_ids, _('Manufacturing order is yet not done!')
-
  I start producing the product PC1.
-
  !workflow {model: mrp.production, action: button_produce, ref: mrp_production_mo1}
-
  I create record for producing products with quantity 5.00.
-
  !record {model: mrp.product.produce, id: mrp_product_produce1}:
    product_qty: 5.00
    mode: 'consume_produce'
-
  Finally my production order is done.
-
  !python {model: mrp.product.produce}: |
    from tools.translate import _
    prod_obj = self.pool.get('mrp.production')
    prod_ids = prod_obj.search(cr, uid, [('product_id.default_code','=','PC1')])
    self.do_produce(cr, uid, [ref('mrp_product_produce1')], context={'active_ids': prod_ids})
