Odoo 18: Mastering Display Notifications
Pop-up wizards can be intrusive. Sometimes, you just want to nudge the user: "Hey, that saved successfully" or "Watch out, credit limit exceeded." In Odoo 18, the Display Notification system allows you to send these toast messages directly from your Python code without writing a single line of JavaScript.
In this tutorial, we will implement a Smart Credit Limit Warning system. Instead of blocking the sale, we will display a sticky warning notification when a salesperson confirms an order for a customer who owes too much money.
Why use Display Notifications?
- Non-blocking: The user can continue working without closing a modal.
- Contextual: Appear in the top-right, standardizing feedback.
- Flexible: Can be transient (3s fade) or sticky (requires user action).
Step 1: The Python Action
The magic happens by returning a dictionary with the type equal to ir.actions.client and the tag display_notification. This tells the Odoo web client to render a toast.
from odoo import models, api, _
class SaleOrder(models.Model):
_inherit = 'sale.order'
def action_confirm_with_check(self):
# 1. Check Credit Limit
partner = self.partner_id
if partner.credit + self.amount_total > partner.credit_limit:
# Show "Sticky" Warning - User MUST close manually
return {
'type': 'ir.actions.client',
'tag': 'display_notification',
'params': {
'title': _('Credit Limit Exceeded!'),
'message': _('Customer %s is over their limit of %s.') % (partner.name, partner.credit_limit),
'type': 'warning', # Options: success, warning, danger, info
'sticky': True, # True = stays until closed
}
}
# 2. If OK, proceed normally
return super().action_confirm()
Step 2: Triggering from a Button
You can attach this to any button. Let's create a custom server action button in XML to trigger a "Check Status" notification manually.
sale.order.form.notify
sale.order
Step 3: Notification Types Breakdown
type: 'success'
Green background. Best for "Record Saved" or "Email Sent".
type: 'warning'
Orange/Yellow. Use for non-blocking issues like "Credit Limit Reached".
type: 'danger'
Red. Use for "API Error" or "Missing Required Fields".
type: 'info'
Blue/Dark. Good for general status updates.
Conclusion
Odoo 18's display_notification tag gives you a powerful tool to communicate with users without interrupting their flow. By combining Python logic with instant UI feedback, you make your custom modules feel professional and responsive.
Upgrade Your Odoo User Experience?
Need better workflows or custom ERP modules? Our Odoo architects build intuitive, high-performance solutions tailored to your business.
Talk to a practice lead
Need this shipped for your business?
We have shipped 50+ Odoo deployments in the US, India, and EU since 2024. Bring your roadmap and your current system; we come back with a written fixed-price brief in 48 hours.
About the author
Founder & CEO, Braincuber Technologies
Founder and CEO of Braincuber. Has scoped and shipped 500+ Odoo, AI, and cloud projects for US mid-market and global brands. Takes every founder call personally — no SDR layer between buyers and the people building the system.
