Pular para o conteúdo
Menu
Esta pergunta foi sinalizada
2 Respostas
29076 Visualizações

I want to raise an error if something specific happens and also show it in the UI. how can I do it?

Avatar
Cancelar
Melhor resposta

You can raise any odoo exception which will show the error message in the popup.

Ex:

from odoo.exceptions import ValidationError

raise ValidationError("This is error message.")


Avatar
Cancelar
Melhor resposta

UserError exception should be used in all cases where some action should not be allowed, when it goes against logic.

        if not self.checkout_ids:
            raise exceptions.UserError('Select at least one Checkout to send messages to.')
        if not self.message_body:
            raise exceptions.UserError('Write a message body to send.')

To Know More About different types of exceptions refer :

https://www.cybrosys.com/blog/raising-exceptions-odoo-13

Avatar
Cancelar
Publicações relacionadas Respostas Visualizações Atividade
2
fev. 24
24769
1
ago. 23
2178
1
jul. 22
3014
2
mar. 22
2784
0
nov. 20
6691