'Move all non-done lines into a new backorder picking. If the key \'do_only_split\' is given in the context, then move all lines not in context.get(\'split\', []) instead of all non-done lines.'

@api.multi
def _create_backorder(self, backorder_moves=[]):

    backorders = self.env['stock.picking']
    for picking in self:
        backorder_moves = (backorder_moves or picking.move_lines)
        if self._context.get('do_only_split'):
            not_done_bo_moves = backorder_moves.filtered((lambda move: (move.id not in self._context.get('split', []))))
        else:
            not_done_bo_moves = backorder_moves.filtered((lambda move: (move.state not in ('done', 'cancel'))))
        if (not not_done_bo_moves):
            continue
        backorder_picking = picking.copy({'name': '/', 'move_lines': [], 'pack_operation_ids': [], 'backorder_id': picking.id})
        picking.message_post(body=(_('Back    order    <em>%s</em>    <b>created</b>.') % backorder_picking.name))
        not_done_bo_moves.write({'picking_id': backorder_picking.id})
        if (not picking.date_done):
            picking.write({'date_done': time.strftime(DEFAULT_SERVER_DATETIME_FORMAT)})
        backorder_picking.action_confirm()
        backorder_picking.action_assign()
        backorders |= backorder_picking
    return backorders
