我在 odoo 中使用了很多开发者模式,因此我每次需要时都必须进行配置并设置dev mode
有没有办法将此开发者模式设为默认
非常感谢你
答案 0 :(得分:2)
你可以非常轻松地启用odoo dev模式!
您可以使用名为Odoo Debug的Chrome扩展程序:
或称为Odoo Easy Debug的Firefox扩展程序:
此致
答案 1 :(得分:0)
默认情况下,您不需要chrome或firefox扩展来激活和设置调试模式。您可以使用Odoo框架执行类似以下代码的操作。这取自this Odoo module,至少在Odoo v8中起作用
使用设置值
创建一个类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: {}'
)