Files
odoo_source/addons/mail/models/ir_qweb.py
T
Gorash ca4fe12a37 [IMP] base: rename var option into compile_context
In order to make it easier to understand the code of qweb.

Part-of: odoo/odoo#85110
2022-03-29 10:56:16 +02:00

17 lines
622 B
Python

# -*- coding: utf-8 -*-
from odoo import models
class IrQweb(models.AbstractModel):
""" Add ``raise_on_code`` option for qweb. When this option is activated
then all directives are prohibited.
"""
_inherit = 'ir.qweb'
def _get_template_cache_keys(self):
return super()._get_template_cache_keys() + ['raise_on_code']
def _compile_directives(self, el, compile_context, indent):
if compile_context.get('raise_on_code'):
raise PermissionError("This rendering mode prohibits the use of directives.")
return super()._compile_directives(el, compile_context, indent)