In this blog, we can discuss how we can create user notifications in odoo. In odoo, we can notify the status of the specific actions by using different types of Exceptions and by changing the states of the required documents/records.
In some cases, odoo uses sticky notifications, the rainbow man effect, and alerts for informing the user.
The actions are notified by
1. Sticky Notification
2. Rainbow man
We can return sticky notifications in our function based on the conditions that we need.
By default, odoo has some sticky notifications.
By using the python code
The above code will generate a notification like below
title: Title of notification.
message: Message to display.
sticky: Boolean value (optional) if the true user must dismiss the notification.
className : CSS class (optional).
The above code will return
The above code will return the following
The next one is the rainbow man effect. We can see a rainbow man effect in default odoo while doing reconciliation.
You can add this feature to your function by simply adding the following code
The above function will return a rainbow man with a custom message. fadeout can be slow, fast, and no.
The next one is Alerts we can create different alerts for our specific conditions and actions in our form view.
This is from the invoice which appears when there are outstanding payments.
We can send these types of notifications to our custom modules for particular conditions.
We can either add to the existing models or the custom models which we created. The above code indicates the addition of the notification to an existing model(sale. order).
In that case, we have to use XPath for adding the notification.
Actually, this notification contains a div. If we want to redirect to any other forms we can include it in that div with a tag with the field related to the required form. In the above example, we can redirect to the sales team of the corresponding sales order. We can assign different classes to the div for changing its look and appearance (alert alert-info, alert alert-warning, alert alert-danger, etc..)