Odoo Mindscape. Understand Odoo faster. Explore modules, fields, dependencies and version differences in one place instead of digging through the source code.

Module: Website

Entity: website.published.mixin

Compute Method: _compute_can_publish

Inputs Method Outputs
""" This method can be overridden if you need more complex rights
        management than just write access to the model.
        The publish widget will be hidden and the user won't be able to change
        the 'website_published' value if this method sets can_publish False """
for record in self:
            try:
                # Some main_record might be in sudo because their content needs
                # to be rendered by a template even if they were not supposed
                # to be accessible
                # TODO in master, instead of this we should ensure main_object
                # (which calls can_publish) is ensured to not be in sudo for all
                # renderings, and sudo() only the required operations if needed.
                # See REVIEW_CAN_PUBLISH_UNSUDO
                plain_record = record.sudo(flag=False) if self._context.get('can_publish_unsudo_main_object', False) else record
                plain_record.check_access_rights('write')
                plain_record.check_access_rule('write')
                record.can_publish = True
            except AccessError:
                record.can_publish = False

Back to entity