未捕获的承诺 > Missing field string information for the field ‘auth_oauth_google_enabled‘ from the ‘res.co

odoo16 点击设置时出现错

UncaughtPromiseError

未捕获的承诺 > Missing field string information for the field 'auth_oauth_google_enabled' from the 'res.config.settings' model

Error: Missing field string information for the field 'auth_oauth_google_enabled' from the 'res.config.settings' model
    at http://localhost:8066/web/assets/636-8bc3271/web.assets_backend.min.js:6613:258
    at traverse (http://localhost:8066/web/assets/636-8bc3271/web.assets_backend.min.js:6608:200)
    at http://localhost:8066/web/assets/636-8bc3271/web.assets_backend.min.js:6608:242
    at Function.each (http://localhost:8066/web/assets/606-0de3136/web.assets_common.min.js:173:149)
    at traverse (http://localhost:8066/web/assets/636-8bc3271/web.assets_backend.min.js:6608:211)
    at http://localhost:8066/web/assets/636-8bc3271/web.assets_backend.min.js:6608:242
    at Function.each (http://localhost:8066/web/assets/606-0de3136/web.assets_common.min.js:173:149)
    at traverse (http://localhost:8066/web/assets/636-8bc3271/web.assets_backend.min.js:6608:211)
    at http://localhost:8066/web/assets/636-8bc3271/web.assets_backend.min.js:6608:242
    at Function.each (http://localhost:8066/web/assets/606-0de3136/web.assets_common.min.js:173:149)

查下源码,发现重装“OAuth2身份验证”可以正常使用了,但登录界面多了个官方登录,可能是某个模块修改设置时把相关字段替掉了

卸载此模块后,错误提示消失,正常使用了

class ResConfigSettings(models.TransientModel):
    _inherit = 'res.config.settings'

    @api.model
    def get_uri(self):
        return "%s/auth_oauth/signin" % (self.env['ir.config_parameter'].get_param('web.base.url'))

    auth_oauth_google_enabled = fields.Boolean(string='Allow users to sign in with Google')
    auth_oauth_google_client_id = fields.Char(string='Client ID')
    server_uri_google = fields.Char(string='Server uri')

    @api.model
    def get_values(self):
        res = super(ResConfigSettings, self).get_values()
        google_provider = self.env.ref('auth_oauth.provider_google', False)
        if google_provider:
            res.update(
                auth_oauth_google_enabled=google_provider.enabled,
                auth_oauth_google_client_id=google_provider.client_id,
                server_uri_google=self.get_uri())
        return res

    def set_values(self):
        super().set_values()
        google_provider = self.env.ref('auth_oauth.provider_google', False)
        if google_provider:
            google_provider.write({
                'enabled': self.auth_oauth_google_enabled,
                'client_id': self.auth_oauth_google_client_id,
            })

猜你喜欢

转载自blog.csdn.net/fqfq123456/article/details/132037080