'Create work orders. And probably do stuff, like things.'

@api.multi
def button_plan(self):

    orders_to_plan = self.filtered((lambda order: (order.routing_id and (order.state == 'confirmed'))))
    for order in orders_to_plan:
        quantity = (order.product_uom_id._compute_quantity(order.product_qty, order.bom_id.product_uom_id) / order.bom_id.product_qty)
        (boms, lines) = order.bom_id.explode(order.product_id, quantity, picking_type=order.bom_id.picking_type_id)
        order._generate_workorders(boms)
    return orders_to_plan.write({'state': 'planned'})
