Search 1.9 billion lines of Odoo code on GitHub

cms_status_message

Author: Camptocamp, Odoo Community Association (OCA)
License: LGPL-3
Branch: 11.0
Repository: Change2improve/website-cms
Dependencies: website
Languages: JavaScript (85, 15.9%), PO File (74, 13.9%), Python (198, 37.1%), XML (70, 13.1%), and reStructuredText (107, 20.0%)
Other branches: 10.0, 13.0, and 9.0
Other repositories: BTETON/website-cms, CompassionCH/website-cms, ERPLibre/website-cms, ForgeFlow/website-cms, Gabinete-Digital/website-cms, Guobower/website-cms, Ingeos/website-cms, JazziMc/website-cms, MjAbuz/website-cms, NL66278/website-cms, NeatNerdPrime/website-cms, Nooka10/website-cms, OCA/website-cms, PCatinean/website-cms, SeuMarco/website-cms, TDu/website-cms, TelmoSenseFly/website-cms, VisiionSolucionesTecnologicas/website-cms, akretion/website-cms, anhvu-sg/website-cms, apetbiz/website-cms, aryajimbaran/website-cms, bishalgit/website-cms, bvkl/website-cms, caiuka/website-cms, camptocamp/website-cms, coobyHQ/odoo-saas-tools, don-systems/website-cms, elvirekemajou/website-cms, frankchongli/website-cms, gfcapalbo/website-cms, grindtildeath/website-cms, haroldtamo/website-cms, hbrunn/website-cms, hinfo506/website-cms, isoscl/website-cms, josueBulle/website-cms, kevin070982/website-cms, leemannd/website-cms, lideritjnma/website-cms, lukehuang/website-cms, one2pret/website-cms, osfp-Pakistan/website-cms, ossamagharib/website-cms, pscloud/website-cms, py-web/website-cms, ravishekharco/website-cms, redcor/website-cms, rsullivan2704/website-cms, sanube/website-cms, simahawk/website-cms, steingabelgaard/website-cms, wahello/website-cms, and x0rzkov/odoo-website-cms

<a class="reference external image-reference" href="http://www.gnu.org/licenses/LGPL-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-lgpl--3-blue.svg"> </a> <a name="cms-status-message"></a> <h2>CMS status message</h2> <p>A &quot;status message&quot; is an important message that you want to show to users.</p> <p>For instance: a user submit a form or does a specific action and you want to report the status of this action like &quot;your profile has been updated&quot; or &quot;Your upgrade has been successful.&quot;.</p> <p>This module allows to easily display this kind of messages to your users.</p> <p>Messages are displayed using Twitter bootstrap alerts.</p> <p>You can add several messages: they will be displayed one after another.</p> <a name="usage"></a> <h3>Usage</h3> <a name="python-code"></a> <h4>Python code</h4> <p>Set a message:</p> <pre> <code lang="python">msg = _('My important message.') if request.website: request.website.add_status_message(msg)</code> </pre> <p>By default the message type is <code>info</code>. The title (the label at the beginning of the message) matches the message type:</p> <ul class="simple"> <li>'info': 'Info'</li> <li>'success': 'Success'</li> <li>'danger': 'Error'</li> <li>'warning': 'Warning'</li> </ul> <p>You can change message parameters:</p> <pre> <code lang="python">msg = _('Watch out!') if request.website: request.website.add_status_message(msg, type_='warning', title='Oh no')</code> </pre> <p>Messages will be displayed like this:</p> <img alt="./images/preview.png" src="./images/preview.png" /> <a name="autodismiss"></a> <h4>Autodismiss</h4> <p>By default messages will be auto-dismissed after 8 seconds. You can turn this off by setting an ir.config_param like:</p> <pre> <code>cms_status_message.autodismiss = 0</code> </pre> <p>You can customize the timeout by setting the key:</p> <pre> <code>cms_status_message.autodismiss_timeout = 3000 # milliseconds</code> </pre> <p>You can also customize this on demand when you create the message:</p> <pre> <code lang="python">msg = _('I will disappear more slowly') options = {'autodismissTimeout': 10000} if request.website: request.website.add_status_message(msg, dismiss_options=options)</code> </pre> <a name="javascript-code"></a> <h4>Javascript code</h4> <p>Dependencies:</p> <pre> <code lang="javascript">var msg_tool = require('cms_status_message.tool'); var core = require('web.core'); var _t = core._t;</code> </pre> <p>Inject a custom message on the fly:</p> <pre> <code lang="javascript">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'); });</code> </pre> <p>Add a status message to the session, useful if you want to show the message only after a redirect:</p> <pre> <code lang="javascript">var msg = _t('Contratulations! You made it!.'); var options = {'title': _('My title'), 'dismissible': false}; msg_tool.add_message(msg, options);</code> </pre> <a name="customize-appereance"></a> <h4>Customize appereance</h4> <p>By default the alert box is added on top of <code>&lt;main /&gt;</code> content. If you want to customize this behavior just override or disable <code>cms_status_message.add_status_message</code> template.</p> <a name="test-your-theme-look-and-feel"></a> <h4>Test your theme look and feel</h4> <p>Go to <cite>/cms/status-message/display-test</cite> to see how messages will look like when your theme is applied.</p> <a name="bug-tracker"></a> <h3>Bug Tracker</h3> <p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/website-cms/issues">GitHub Issues</a>. 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.</p> <a name="credits"></a> <h3>Credits</h3> <a name="contributors"></a> <h4>Contributors</h4> <ul class="simple"> <li>Simone Orsi <a class="reference external" href="mailto:simone.orsi&#64;camptocamp.com">simone.orsi&#64;camptocamp.com</a></li> </ul> <a name="maintainer"></a> <h4>Maintainer</h4> <a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a> <p>This module is maintained by the OCA.</p> <p>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.</p> <p>To contribute to this module, please visit <a class="reference external" href="https://odoo-community.org">https://odoo-community.org</a>.</p>