Skip to main content
License: AGPL-3

CMS delete content

Basic features for deleting content via frontend.

Features

  • register your own custom delete confirmation view per-model

  • use cms_status_message to show confirmation message for deletion

  • generic template for asking delete confirmation

  • new fields and parameters on website.published.mixin to handle delete links and redirects

Usage

Delete button and behavior

To add a delete button:

<a class="btn btn-danger cms_delete_confirm" t-att-href="object.cms_delete_confirm_url">Delete</a>

When you click on a confirmation dialog pops up.

If you hit cancel the popup is closed. If you hit submit the item is deleted and you get redirected to your model’s cms_after_delete_url. By default is /.

Customization

Custom per-model delete messge

class MyModel(models.Model):
    _inherit = "my.model"

    @api.multi
    def msg_content_delete_confirm(self):
        self.ensure_one()
        return _('Are you sure you want to delete "%s"?.') % self.name

Custom “after delete URL”

When you are viewing a content and you delete it you want to be redirected to some other place.

By default you get redirected to the root of the website.

To change this behavior just override the attribute in your model declaration:

class MyModel(models.Model):
    _inherit = "my.model"

    cms_after_delete_url = '/foo'

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 ?redirect= in the url, like:

<a class="btn btn-danger cms_delete_confirm" t-attf-href="#{object.cms_delete_confirm_url}?redirect=">Delete</a>

Custom global delete confirm message appeareance

<template id="delete_confirm" inherit_id="cms_delete_content.delete_confirm">

    <xpath expr="//h4[@id='delete_confirm']" position="replace">
        <h1 t-esc="main_object.msg_content_delete_confirm()">I want it bigger!</h1>
    </xpath>

</template>

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.

Release files for odoo9-addon-cms-delete-content 9.0.1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for odoo9-addon-cms-delete-content 9.0.1.0.0
File Interpreter ABI Platform
odoo9_addon_cms_delete_content-9.0.1.0.0-py2-none-any.whl Python 2 none any Details

Release files / odoo9_addon_cms_delete_content-9.0.1.0.0-py2-none-any.whl

Download URL odoo9_addon_cms_delete_content-9.0.1.0.0-py2-none-any.whl
Size 25.1 kB
Tags Python 2
SHA-256 checksum
How to use checksums
6f60884fe8a2acc3118e98f6eb73eb67d4917f1fb86f373b14cc0b2ced824978
BLAKE2b-256 checksum
How to use checksums
6222e2178519dd344c8d699fa85321134b97bdcc22eea3fda216204765cad7a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page