|
|
""" 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
self.env['website'].get_current_website()._check_user_can_modify(plain_record)
record.can_publish = True
except AccessError:
record.can_publish = False
|
|