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

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

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

What Is The Difference Between “Quarantine” And “Isolation , What are some of these differences, and why do they matter? Contagiousness. One difference between COVID-19 and influenza is that the former  Difference Between Content Curation and Content Creation (Comments Off on Difference Between Content Curation and Content Creation). Many argue that one is better than the other, with content creators criticizing content curators and vice-versa.

when an exception is raised in python. it propagates up the call stack until it is processed on Odoo. the RPC layer that answers the calls made by the web client catches all exceptions and depending on the exception class, it will trigger different possible behaviors on web client.

An UserError will display error message in the user interface its define in odoo.exceptions class. The code of recipe changes the OSError to UserError to ensure the message is displayed in a friendly way. In all cases, the current database transaction is rolled back. In Odoo 9 and 10 use UserError to display error message.

Warning: in Odoo 8 openerp.exception.Warning played the role of UserError in 9 and 10 its deprecated because the name was deceptive (it is an error not warning) it collided with python built-in Warning class, it is kept for backward compatibility and you should use UserError in odoo 9 and 10.

in your case while we return a warning it means its only shows the warning message to user and transaction will not rollback.

What Is the Difference Between Influenza and COVID-19?, What is the difference between isolation and quarantine? Isolation and quarantine are public health practices used to protect the public by preventing exposure to  The key difference between which and what is that which is generally used in cases where there is a limited choice whereas what is used when the choice is bigger. Which and what are two common interrogative pronouns in the English language. The origin of what lies in the Old English word hwæt. In the same manner, the origin of which lies in

A warning is a python keyword and UserError is used in Odoo, and in odoo warning is deprecated in odoo v9 an onwards.

SO We used UserError in Odoo.

What is the difference between isolation and quarantine?, They use a different term instead: antisocial personality disorder. Most experts believe psychopaths and sociopaths share a similar set of traits. People like this  People often use the terms internet and web interchangeably, but these are two different technologies. We looked at both technologies to help you understand the difference between the two.

What's the Difference Between a Sociopath and a Psychopath?, memory, day-to-day life, and communication. Alzheimer's disease is the most common type of dementia. Read the differences and overlap between the two. The Percentage Difference Calculator (% difference calculator) will find the percent difference between two positive numbers greater than 0. Percentage difference is usually calculated when you want to know the difference in percentage between two numbers. For this calculator, the order of the numbers does not matter as we are simply dividing

What's the Difference Between Dementia and Alzheimer's Disease?, What is the difference between Alzheimer's and dementia? Get an overview of each and learn about early symptoms, risk factors, diagnosis and treatment. Which vs. That: What’s the Difference in Usage? To understand when to use that or which, it’s important to understand clauses.A defining clause (also called an essential clause or a restrictive clause) gives information essential to the meaning of the sentence.

Dementia vs. Alzheimer's Disease: What Is the Difference?, Dementia is caused by different diseases that affect the brain. Alzheimer's disease is the most common. Some other common types of dementia include vascular  The percentage difference calculator is here to help you compare two numbers. Here we will show you how to calculate the percentage difference between two numbers and, hopefully, to properly explain what the percentage difference is as well as some common mistakes. In the following article, we will also show you the percentage difference formula.