This article will teach you how to send and display a sticky notification in Odoo15. You will also learn how to create and customize these notifications.
Send Custom Notification in Odoo
In Odoo we can create and send custom sticky notifications on some event or action. For this purpose, Odoo provides different types of notifications.
Following are the notifications that fire on some action.
- Sticky Notification
- Rainbow Man Effect
- Alert
- Raise Exception/Validation
In this article, I am going to show you how to send a sticky notification on a button-click event.
Display Only Sticky Notification in Odoo15
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def cmd_send_notification(self): | |
return { | |
'type': 'ir.actions.client', | |
'tag': 'display_notification', | |
'params': { | |
'title': _('Your Custom Notification Title'), | |
'message': 'Your Custom Message...', | |
'sticky': False, | |
} | |
} |
Display Sticky Notification with a Link Button in Odoo15
Return Action With Sticky Notification in Odoo15
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def cmd_send_notification(self): | |
action = self.env.ref('module_name.id_of_custom_action_window') | |
return { | |
'type': 'ir.actions.client', | |
'tag': 'display_notification', | |
'params': { | |
'title': _('Your Custom Notification Title'), | |
'message': '%s', | |
'links': [{ | |
'label': self.customer_id.name, | |
'url': f'#action={action.id}&id={self.customer_id.id}&model=res.partner', | |
}], | |
'sticky': False, | |
'next': { | |
'type': 'ir.actions.act_window', | |
'res_model': 'res.partner', | |
'res_id': self.customer_id.id, | |
'views': [(False,'form')] | |
}, | |
} | |
} |
0 Comments