context = {}
        if list_lines:
            new_list_lines = SalesLines.objects.filter(
                pk__in=[int(x) for x in list_lines]
            ).exclude(
                invoice__isnull=False
            )

            if new_list_lines:
                new_pk = new_list_lines.first()
                if new_pk:
                    context = SalesLines.create_invoice_from_order(
                        new_pk.order.pk,
                        [x['pk'] for x in new_list_lines.values('pk')])
                    return context
                else:
                    error = _('Pedido no encontrado')
            else:
                error = _('Lineas no relacionadas con pedido')
        else:
            error = _('Lineas no seleccionadas')
        context['error'] = error
        return context

def create_invoice_from_albaran(pk, list_lines):
        MODEL_SOURCE = SalesAlbaran
        MODEL_FINAL = SalesInvoice
        url_reverse = 'CDNX_invoicing_invoicesaless_list'
        # type_doc
        msg_error_relation = _("Hay lineas asignadas a facturas")
        msg_error_not_found = _('Sales albaran not found')
        msg_error_line_not_found = _('Todas las lineas ya se han pasado a facturas')

        return SalesLines.create_document_from_another(pk, list_lines,
                                                       MODEL_SOURCE, MODEL_FINAL, url_reverse,
                                                       msg_error_relation, msg_error_not_found, msg_error_line_not_found,
                                                       False)
        """
        context = {}
        if list_lines:
            new_list_lines = SalesLines.objects.filter(
                pk__in=[int(x) for x in list_lines]
            ).exclude(
                invoice__isnull=False
            )

            if new_list_lines:
                new_pk = new_list_lines.first()
                if new_pk:
                    context = SalesLines.create_invoice_from_order(
                        new_pk.order.pk,
                        [x['pk'] for x in new_list_lines.values('pk')])
                    return context
                else:
                    error = _('Pedido no encontrado')
            else:
                error = _('Lineas no relacionadas con pedido')
        else:
            error = _('Lineas no seleccionadas')
        context['error'] = error
        return context
        """