Search 1.9 billion lines of Odoo code on GitHub

cms_delete_content

Author: Camptocamp,Odoo Community Association (OCA)
License: LGPL-3
Branch: 10.0
Repository: Change2improve/website-cms
Dependencies: cms_status_message, and website
Languages: JavaScript (60, 17.8%), PO File (31, 9.2%), Python (162, 47.9%), XML (32, 9.5%), and reStructuredText (53, 15.7%)
Other branches: 11.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, bishalgit/website-cms, bvkl/website-cms, caiuka/website-cms, camptocamp/website-cms, elvirekemajou/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, 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-delete-content"></a> <h2>CMS delete content</h2> <p>Basic features for deleting content via frontend.</p> <a name="features"></a> <h3>Features</h3> <ul class="simple"> <li>register your own custom delete confirmation view per-model</li> <li>use <code>cms_status_message</code> to show confirmation message for deletion</li> <li>generic template for asking delete confirmation</li> <li>new fields and parameters on <code>website.published.mixin</code> to handle delete links and redirects</li> </ul> <a name="usage"></a> <h3 class="with-subtitle">Usage</h3> <h3 class="section-subtitle" id="delete-button-and-behavior"><span class="section-subtitle">Delete button and behavior</span></h3> <p>To add a delete button:</p> <pre> <code lang="html">&lt;a class=&quot;btn btn-danger cms_delete_confirm&quot; t-att-href=&quot;object.cms_delete_confirm_url&quot;&gt;Delete&lt;/a&gt;</code> </pre> <p>When you click on a confirmation dialog pops up.</p> <p>If you hit <code>cancel</code> the popup is closed. If you hit submit the item is deleted and you get redirected to your model's <code>cms_after_delete_url</code>. By default is <code>/</code>.</p> <a name="customization"></a> <h3>Customization</h3> <a name="custom-per-model-delete-messge"></a> <h4>Custom per-model delete messge</h4> <pre> <code lang="python">class MyModel(models.Model): _inherit = &quot;my.model&quot; &#64;api.multi def msg_content_delete_confirm(self): self.ensure_one() return _('Are you sure you want to delete &quot;%s&quot;?.') % self.name</code> </pre> <a name="custom-after-delete-url"></a> <h4>Custom &quot;after delete URL&quot;</h4> <p>When you are viewing a content and you delete it you want to be redirected to some other place.</p> <p>By default you get redirected to the root of the website.</p> <p>To change this behavior just override the attribute in your model declaration:</p> <pre> <code lang="python">class MyModel(models.Model): _inherit = &quot;my.model&quot; cms_after_delete_url = '/foo'</code> </pre> <p>Note: if you want to customize it on demand for particular pages, or you are deleting an item from another page (like a management page) you can pass <code>?redirect=</code> in the url, like:</p> <pre> <code lang="html">&lt;a class=&quot;btn btn-danger cms_delete_confirm&quot; t-attf-href=&quot;#{object.cms_delete_confirm_url}?redirect=&quot;&gt;Delete&lt;/a&gt;</code> </pre> <a name="custom-global-delete-confirm-message-appeareance"></a> <h4>Custom global delete confirm message appeareance</h4> <pre> <code lang="xml">&lt;template id=&quot;delete_confirm&quot; inherit_id=&quot;cms_delete_content.delete_confirm&quot;&gt; &lt;xpath expr=&quot;//h4[&#64;id='delete_confirm']&quot; position=&quot;replace&quot;&gt; &lt;h1 t-esc=&quot;main_object.msg_content_delete_confirm()&quot;&gt;I want it bigger!&lt;/h1&gt; &lt;/xpath&gt; &lt;/template&gt;</code> </pre> <a name="bug-tracker"></a> <h2>Bug Tracker</h2> <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> <h2>Credits</h2> <a name="contributors"></a> <h3>Contributors</h3> <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> <h3>Maintainer</h3> <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>