v 10.0 v 11.0 Third Party 200
Download for v 11.0 Deploy on Odoo.sh
Availability
Odoo Online
Odoo.sh
On Premise
Odoo Apps Dependencies Website Builder (website)
Discuss (mail)
Lines of code 226
Technical Name cms_status_message
LicenseLGPL-3
Versions 16.0 10.0 11.0 13.0
You bought this module and need support? Click here!

CMS status message

A "status message" is an important message that you want to show to users.

For instance: a user submit a form or does a specific action and you want to report the status of this action like "your profile has been updated" or "Your upgrade has been successful.".

This module allows to easily display this kind of messages to your users.

Messages are displayed using Twitter bootstrap alerts.

You can add several messages: they will be displayed one after another.

Usage

Python code

Set a message:

msg = _('My important message.')
if request.website:
    request.website.add_status_message(msg)

By default the message type is info. The title (the label at the beginning of the message) matches the message type:

  • 'info': 'Info'
  • 'success': 'Success'
  • 'danger': 'Error'
  • 'warning': 'Warning'

You can change message parameters:

msg = _('Watch out!')
if request.website:
    request.website.add_status_message(msg, type_='warning', title='Oh no')

Messages will be displayed like this:

./images/preview.png

Autodismiss

By default messages will be auto-dismissed after 8 seconds. You can turn this off by setting an ir.config_param like:

cms_status_message.autodismiss = 0

You can customize the timeout by setting the key:

cms_status_message.autodismiss_timeout = 3000  # milliseconds

You can also customize this on demand when you create the message:

msg = _('I will disappear more slowly')
options = {'autodismissTimeout': 10000}
if request.website:
    request.website.add_status_message(msg, dismiss_options=options)

Javascript code

Dependencies:

var msg_tool = require('cms_status_message.tool');
var core = require('web.core');
var _t = core._t;

Inject a custom message on the fly:

msg = {
    'msg': _t('Item unpublished.'),
    'title': _t('Warning'),
    'type': 'warning'
}
msg_tool.render_messages(msg).then(function(html) {
    // wipe existing
    $('.status_message').remove();
    // inject new
    $(html).hide().prependTo('#wrap').fadeIn('slow');
});

Add a status message to the session, useful if you want to show the message only after a redirect:

var msg =  _t('Contratulations! You made it!.');
var options = {'title': _('My title'), 'dismissible': false};
msg_tool.add_message(msg, options);

Customize appereance

By default the alert box is added on top of <main /> content. If you want to customize this behavior just override or disable cms_status_message.add_status_message template.

Test your theme look and feel

Go to /cms/status-message/display-test to see how messages will look like when your theme is applied.

Bug Tracker

Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed feedback.

Credits

Contributors

Maintainer

Odoo Community Association

This module is maintained by the OCA.

OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

To contribute to this module, please visit https://odoo-community.org.

Please log in to comment on this module

  • The author can leave a single reply to each comment.
  • This section is meant to ask simple questions or leave a rating. Every report of a problem experienced while using the module should be addressed to the author directly (refer to the following point).
  • If you want to start a discussion with the author, please use the developer contact information. They can usually be found in the description.
Please choose a rating from 1 to 5 for this module.