Saturday, July 16, 2022

[FIXED] What is the difference between "warning" and "UserError" in odoo?

Issue

Warning:

warning = {
                    'title': _('Warning!'),
                    'message': _('Exists the discount limit'),
                }
            return {'warning': warning}

UserError

raise UserError(_('Exists the discount limit'))

What is the difference between Warning and UserError in odoo


Solution

To answer it in simple manner, both are same in odoo. Because if you check in odoo/exception.py refer odoo exception here

It clearly understood that it is referring Warning as UserError. odoo warning is deprecated in odoo v9 and v10 due to ambiguity or collision with python built-in.

To get the information about python warning refer python warning documentation.

So it is recommended to use odoo.exceptions.UserError instead of Warning



Answered By - Janarthanan Ramu
Answer Checked By - Marie Seifert (PHPFixing Admin)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.