如何在 ODOO 中将开发者模式设置为默认模式

How to set developer Mode as default in ODOO

我在 odoo 中使用了很多开发者模式,所以我每次需要时都必须去配置并设置 dev mode 有什么方法可以将此开发者模式设置为默认模式 非常感谢

您可以非常轻松地启用 odoo 开发模式!

您可以使用名为 Odoo Debug 的 chrome 扩展:

Odoo Debug

或者名为 Odoo Easy Debug 的 Firefox 扩展:

Odoo Easy Debug

此致,

您不需要 chrome 或 firefox 扩展来激活和设置 Odoo 默认的调试模式。您可以使用 Odoo 框架执行类似以下代码的操作。这取自 this Odoo module 并且至少在 Odoo v8

中有效
  • 使用设置值

    创建一个class
    class DevelopmentToolsConfigSettings(models.TransientModel):
    
        _name = 'development_tools.config.settings'
    
        development_mode = fields.Boolean(
            string='Development mode as default',
            required=False,
            readonly=False,
            index=False,
            default=True,
            help='Set development mode by default'
        )
    
        @api.model
        def get_default_values(self, values):
            return dict(
                development_mode=self.get_debug_mode(),
            )            
    
        def get_debug_mode(self):
            param = self._get_parameter('development_mode')
    
            if param:
                value = self._safe_eval(param.value, bool)
            else:
                value = self._defaults['development_mode']
    
            return value
    
        def _set_debug_mode(self):
            param = self._get_parameter('development_mode', force=True)
            param.value = unicode(self.development_mode)         
    
  • 覆盖 web.Home 控制器并添加自动调试模式行为:

    from openerp.http import route, request, Controller, redirect_with_hash
    import openerp.addons.web.controllers.main as webmain
    from openerp.tools.translate import _
    from logging import getLogger
    import werkzeug
    
    _logger = getLogger(__name__)
    
    
    class Home(webmain.Home):
    
        @route()
        def web_client(self, s_action=None, **kw):
            result = None
    
            if not request.debug and request.db and self._get_debug_mode():
                _logger.info(self._debug_message)
                result = self._build_debug_response()
    
            return result or super(Home, self).web_client(s_action, **kw)
    
        def _get_debug_mode(self):
            config = request.env['development_tools.config.settings']
            debug = config.get_debug_mode()
    
            return debug == True
    
        def _build_debug_response(self):
            result = None
    
            try:
                query = request.params
                query.update({'debug': u''})
                url = '/web?' + werkzeug.url_encode(query)
                result = redirect_with_hash(url)
            except Exception as ex:
                _logger.error(self._error_response.format(ex))
    
            return result
    
        _debug_message = _(u'Auto-redirect to enter in debug mode')
    
        _error_response = _(
            u'The debug response could not be built.\n'
            u'System has said: {}'
        )