'Check that a manufacturing order create the right procurements when the route are set on
a parent category of a product'

def test_procurement_2(self):

    all_categ_id = self.env['product.category'].search([('parent_id', '=', None)], limit=1)
    child_categ_id = self.env['product.category'].search([('parent_id', '=', all_categ_id.id)], limit=1)
    for bom_line_id in self.bom_1.bom_line_ids:
        self.assertEquals(len(bom_line_id.product_id.route_ids), 0)
        bom_line_id.product_id.categ_id = child_categ_id
    self.warehouse = self.env.ref('stock.warehouse0')
    mto_route = self.warehouse.mto_pull_id.route_id
    mto_route.product_categ_selectable = True
    all_categ_id.write({'route_ids': [(6, 0, [mto_route.id])]})
    production_product_4 = self.env['mrp.production'].create({'name': 'MO/Test-00002', 'product_id': self.product_4.id, 'product_qty': 1, 'bom_id': self.bom_1.id, 'product_uom_id': self.product_4.uom_id.id})
    procurement = self.env['procurement.order'].search([('group_id', '=', production_product_4.procurement_group_id.id), ('product_id', 'in', self.bom_1.bom_line_ids.mapped('product_id.id'))])
    self.assertEqual(len(procurement), 2)
