Hilfe

0

Keycloak Authentication on v12

Avatar
Karim Gillani

Using: Odoo 12.0-20190128 (Community Edition)

am trying to get Keycloak working on Odoo using the base OAUTH2 setup.  I am getting an access denied.  In my keycloak server, I see the user in the session.  I suspect the mapping is not correct.  Any suggestions would be appreciated...

Errors in log:

2019-03-03 22:43:11,701 1 ERROR db odoo.addons.auth_oauth.controllers.main: OAuth2: Expecting value: line 1 column 1 (char 0) 

Traceback (most recent call last):

  File "/usr/lib/python3/dist-packages/odoo/addons/auth_oauth/controllers/main.py", line 142, in signin

    credentials = env['res.users'].sudo().auth_oauth(provider, kw)

  File "/usr/lib/python3/dist-packages/odoo/addons/auth_oauth/models/res_users.py", line 96, in auth_oauth

    validation = self._auth_oauth_validate(provider, access_token)

  File "/usr/lib/python3/dist-packages/odoo/addons/auth_oauth/models/res_users.py", line 34, in _auth_oauth_validate

    validation = self._auth_oauth_rpc(oauth_provider.validation_endpoint, access_token)

  File "/usr/lib/python3/dist-packages/odoo/addons/auth_oauth/models/res_users.py", line 28, in _auth_oauth_rpc

    return requests.get(endpoint, params={'access_token': access_token}).json()

  File "/usr/lib/python3/dist-packages/requests/models.py", line 850, in json

    return complexjson.loads(self.text, **kwargs)

  File "/usr/lib/python3.5/json/__init__.py", line 319, in loads

    return _default_decoder.decode(s)

  File "/usr/lib/python3.5/json/decoder.py", line 339, in decode

    obj, end = self.raw_decode(s, idx=_w(s, 0).end())

  File "/usr/lib/python3.5/json/decoder.py", line 357, in raw_decode

    raise JSONDecodeError("Expecting value", s, err.value) from None

json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

2019-03-03 22:43:11,704 1 INFO db werkzeug: 172.51.20.1 - - [03/Mar/2019 22:43:11] "GET /auth_oauth/signin?state={%22r%22%3A+%22https%253A%252F%252Fodoo.pathfinder.gov.bc.ca%252Fweb%22%2C+%22p%22%3A+7%2C+%22d%22%3A+%22db%22}&session_state=4946aea0-1a42-4809-a10b-030aaba4c50f&access_token=eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICI1NXhiZzcyaml6NWQ3cEtkbzdwNFhLdTB2VFA2UXMtemthZzFaY1ZKWTZVIn0.eyJqdGkiOiIzNTRkY2EzYi0wMWE4LTRmM2EtODdkZC1iOWZkZThjMzc2YTkiLCJleHAiOjE1NTE2NTM4ODYsIm5iZiI6MCwiaWF0IjoxNTUxNjUyOTg2LCJpc3MiOiJodHRwczovL3Nzby10ZXN0LnBhdGhmaW5kZXIuZ292LmJjLmNhL2F1dGgvcmVhbG1zL3NiYyIsImF1ZCI6Ik9kb28iLCJzdWIiOiI0YjZjODM5YS03NjA0LTRiMzYtOGE1My1lNzI1Mjg5ZGZjNzkiLCJ0eXAiOiJCZWFyZXIiLCJhenAiOiJPZG9vIiwiYXV0aF90aW1lIjoxNTUxNjQ1MTg3LCJzZXNzaW9uX3N0YXRlIjoiNDk0NmFlYTAtMWE0Mi00ODA5LWExMGItMDMwYWFiYTRjNTBmIiwiYWNyIjoiMCIsImFsbG93ZWQtb3JpZ2lucyI6WyIqIl0sInJlYWxtX2FjY2VzcyI6eyJyb2xlcyI6WyJpZGlyIiwib2ZmbGluZV9hY2Nlc3MiLCJhZG1pbiIsInVtYV9hdXRob3JpemF0aW9uIl19LCJyZXNvdXJjZV9hY2Nlc3MiOnsicmVhbG0tbWFuYWdlbWVudCI6eyJyb2xlcyI6WyJ2aWV3LXJlYWxtIiwidmlldy1pZGVudGl0eS1wcm92aWRlcnMiLCJtYW5hZ2UtaWRlbnRpdHktcHJvdmlkZXJzIiwiaW1wZXJzb25hdGlvbiIsInJlYWxtLWFkbWluIiwiY3JlYXRlLWNsaWVudCIsIm1hbmFnZS11c2VycyIsInF1ZXJ5LXJlYWxtcyIsInZpZXctYXV0aG9yaXphdGlvbiIsInF1ZXJ5LWNsaWVudHMiLCJxdWVyeS11c2VycyIsIm1hbmFnZS1ldmVudHMiLCJtYW5hZ2UtcmVhbG0iLCJ2aWV3LWV2ZW50cyIsInZpZXctdXNlcnMiLCJ2aWV3LWNsaWVudHMiLCJtYW5hZ2UtYXV0aG9yaXphdGlvbiIsIm1hbmFnZS1jbGllbnRzIiwicXVlcnktZ3JvdXBzIl19LCJhY2NvdW50Ijp7InJvbGVzIjpbIm1hbmFnZS1hY2NvdW50IiwibWFuYWdlLWFjY291bnQtbGlua3MiLCJ2aWV3LXByb2ZpbGUiXX19LCJuYW1lIjoiR2lsbGFuaSwgS2FyaW0gQ0lUWjpFWCIsInByZWZlcnJlZF91c2VybmFtZSI6ImlkaXIva2dpbGxhbmkiLCJnaXZlbl9uYW1lIjoiR2lsbGFuaSwgS2FyaW0gQ0lUWjpFWCIsImVtYWlsIjoia2FyaW0uZ2lsbGFuaUBnb3YuYmMuY2EifQ.MFfD0se0hcI-l6oxL7gJ_RFEDosYBKDZNO3VEVLUyPjhjN8xkK5rGycK_ZyE_D9OFbCBX8E8c9qnQWDrik7i43sfBt6luPKs7TkLQJZHtfOt6ASYsAVKJyJxjZRBm_Pume98MXEBiMEhVCU3Un5V94k3f7ae_lTnE1Vqx-t2QtMeA-KDAFz9m8mL2PbFyOnDnfeb2ar_vjHkPkMxf1iruglSj8-xHYUQ8qMATX6WsxEPLBMlFuRoGdnWstSzz_tzAmQ7sAVY0lY2oWeQVbA5Fj3_oCOMSnwYxhtpaabTPosZs1y9nvTHtBRReKgt88p0dW3FqWWzSWefCD7Lzwho1g&token_type=bearer&expires_in=900&not-before-policy=1548956992 HTTP/1.1" 303 - 2 0.002 5.174

2019-03-03 22:43:11,861 1 INFO db werkzeug: 172.51.20.1 - - [03/Mar/2019 22:43:11] "GET /web/login?oauth_error=2 HTTP/1.1" 200 - 11 0.029 0.065

2019-03-03 22:43:12,172 1 INFO db werkzeug: 172.51.20.1 - - [03/Mar/2019 22:43:12] "GET /web/webclient/qweb?mods= HTTP/1.1" 200 - 1 0.001 0.007

2019-03-03 22:43:12,174 1 INFO db werkzeug: 172.51.20.1 - - [03/Mar/2019 22:43:12] "POST /web/webclient/bootstrap_translations HTTP/1.1" 200 - 1 0.001


I also tried to install the Keycloak auth app (v10) but received errors:

Error:

Odoo Server Error


Traceback (most recent call last):

  File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 757, in parse

    self._tags[rec.tag](rec, de, mode=mode)

  File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 573, in _tag_record

    model = self.env[rec_model]

  File "/usr/lib/python3/dist-packages/odoo/api.py", line 821, in __getitem__

    return self.registry[model_name]._browse((), self)

  File "/usr/lib/python3/dist-packages/odoo/modules/registry.py", line 176, in __getitem__

    return self.models[model_name]

KeyError: 'ir.values'


During handling of the above exception, another exception occurred:


Traceback (most recent call last):

  File "/usr/lib/python3/dist-packages/odoo/http.py", line 654, in _handle_exception

    return super(JsonRequest, self)._handle_exception(exception)

  File "/usr/lib/python3/dist-packages/odoo/http.py", line 312, in _handle_exception

    raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])

  File "/usr/lib/python3/dist-packages/odoo/tools/pycompat.py", line 87, in reraise

    raise value

  File "/usr/lib/python3/dist-packages/odoo/http.py", line 696, in dispatch

    result = self._call_function(**self.params)

  File "/usr/lib/python3/dist-packages/odoo/http.py", line 344, in _call_function

    return checked_call(self.db, *args, **kwargs)

  File "/usr/lib/python3/dist-packages/odoo/service/model.py", line 97, in wrapper

    return f(dbname, *args, **kwargs)

  File "/usr/lib/python3/dist-packages/odoo/http.py", line 337, in checked_call

    result = self.endpoint(*a, **kw)

  File "/usr/lib/python3/dist-packages/odoo/http.py", line 939, in __call__

    return self.method(*args, **kw)

  File "/usr/lib/python3/dist-packages/odoo/http.py", line 517, in response_wrap

    response = f(*args, **kw)

  File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 966, in call_button

    action = self._call_kw(model, method, args, {})

  File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 954, in _call_kw

    return call_kw(request.env[model], method, args, kwargs)

  File "/usr/lib/python3/dist-packages/odoo/api.py", line 749, in call_kw

    return _call_kw_multi(method, model, args, kwargs)

  File "/usr/lib/python3/dist-packages/odoo/api.py", line 736, in _call_kw_multi

    result = method(recs, *args, **kwargs)

  File "<decorator-gen-61>", line 2, in button_immediate_install

  File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_module.py", line 73, in check_and_log

    return method(self, *args, **kwargs)

  File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_module.py", line 444, in button_immediate_install

    return self._button_immediate_function(type(self).button_install)

  File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_module.py", line 553, in _button_immediate_function

    modules.registry.Registry.new(self._cr.dbname, update_module=True)

  File "/usr/lib/python3/dist-packages/odoo/modules/registry.py", line 86, in new

    odoo.modules.load_modules(registry._db, force_demo, status, update_module)

  File "/usr/lib/python3/dist-packages/odoo/modules/loading.py", line 421, in load_modules

    loaded_modules, update_module, models_to_check)

  File "/usr/lib/python3/dist-packages/odoo/modules/loading.py", line 313, in load_marked_modules

    perform_checks=perform_checks, models_to_check=models_to_check

  File "/usr/lib/python3/dist-packages/odoo/modules/loading.py", line 222, in load_module_graph

    load_data(cr, idref, mode, kind='data', package=package, report=report)

  File "/usr/lib/python3/dist-packages/odoo/modules/loading.py", line 68, in load_data

    tools.convert_file(cr, package.name, filename, idref, mode, noupdate, kind, report)

  File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 801, in convert_file

    convert_xml_import(cr, module, fp, idref, mode, noupdate, report)

  File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 864, in convert_xml_import

    obj.parse(doc.getroot(), mode=mode)

  File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 763, in parse

    exc_info[2]

  File "/usr/lib/python3/dist-packages/odoo/tools/pycompat.py", line 86, in reraise

    raise value.with_traceback(tb)

  File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 757, in parse

    self._tags[rec.tag](rec, de, mode=mode)

  File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 573, in _tag_record

    model = self.env[rec_model]

  File "/usr/lib/python3/dist-packages/odoo/api.py", line 821, in __getitem__

    return self.registry[model_name]._browse((), self)

  File "/usr/lib/python3/dist-packages/odoo/modules/registry.py", line 176, in __getitem__

    return self.models[model_name]

odoo.tools.convert.ParseError: "ir.values" while parsing /mnt/extra-addons/auth_keycloak/wizard/keycloak_create_wiz.xml:55, near

<record id="action_purge_model_line_value" model="ir.values">

    <field name="name">Push users to Keycloak</field>

    <field name="key">action</field>

    <field name="key2">client_action_multi</field>

    <field name="model">res.users</field>

    <field name="value" eval="'ir.actions.act_window,%d' % ref('auth_keycloak.keycloak_create_users')"/>

  </record>

Avatar
Verwerfen
4 Antworten
1
Avatar
Hideyuki Otokawa
Best Answer

I've also tried to use odoo with keycloak and met with same thing. After some investigation  I've made a small patch for auth_oauth. In my environemnt, in which the docker conatiner of official image runs, its working..

These are the necessary settings.


Making OAuth provider of keycloak as below;

  •  client id should be specified the one assinged for client in keycloak realm

  •  keycloak checkbox should be marked; it's the new one which I added.

  • auth URL should be specified the endpoint of keycloak ended with 'auth'

  • validation URL should be spefied the endpoint of keycloak ended with 'userinfo

  • scope and data URL are blank.

Next, settings for user accounts by which you'd like to sign-in with keycloak

  • OAtuth provider should be selected the one which you made for keycloak

  • OAuth user id shoud be input email address of the keycloak user accout

Finally, necessary setting of keycloak

  • Creating the mapping from 'email' to 'user_id' in the client mapper.

If everything is okay, then you can sign-in through keycloak as me..

Sorry. I did not put my patch. Please apply this.

diff -c -r -x '*.po' ./models/auth_oauth.py /home/s111403/work/auth_oauth/models/auth_oauth.py
*** ./models/auth_oauth.py2019-03-15 00:52:47.824000000 +0000
--- /home/s111403/work/auth_oauth/models/auth_oauth.py2019-03-14 14:22:21.964000000 +0000
***************
*** 18,23 ****
--- 18,24 ----
      validation_endpoint = fields.Char(string='Validation URL', required=True)  # OAuth provider URL to validate tokens
      data_endpoint = fields.Char(string='Data URL')
      enabled = fields.Boolean(string='Allowed')
+     keycloak = fields.Boolean(string='Keycloak')
      css_class = fields.Char(string='CSS class', default='fa fa-fw fa-sign-in text-primary')
      body = fields.Char(required=True)
      sequence = fields.Integer()
diff -c -r -x '*.po' ./models/res_users.py /home/s111403/work/auth_oauth/models/res_users.py
*** ./models/res_users.py2019-03-15 00:52:47.824000000 +0000
--- /home/s111403/work/auth_oauth/models/res_users.py2019-03-14 15:07:20.572000000 +0000
***************
*** 24,41 ****
      ]
      @api.model
!     def _auth_oauth_rpc(self, endpoint, access_token):
!         return requests.get(endpoint, params={'access_token': access_token}).json()
      @api.model
      def _auth_oauth_validate(self, provider, access_token):
          """ return the validation data corresponding to the access token """
          oauth_provider = self.env['auth.oauth.provider'].browse(provider)
!         validation = self._auth_oauth_rpc(oauth_provider.validation_endpoint, access_token)
          if validation.get("error"):
              raise Exception(validation['error'])
          if oauth_provider.data_endpoint:
!             data = self._auth_oauth_rpc(oauth_provider.data_endpoint, access_token)
              validation.update(data)
          return validation
--- 27,48 ----
      ]
      @api.model
!     def _auth_oauth_rpc(self, endpoint, access_token, provider):
!         oauth_provider = self.env['auth.oauth.provider'].browse(provider)
!         if oauth_provider.keycloak:
!           return requests.get(endpoint, headers={'Authorization': 'bearer ' + access_token}).json()
!         else:
!           return requests.get(endpoint, params={'access_token': access_token}).json()
      @api.model
      def _auth_oauth_validate(self, provider, access_token):
          """ return the validation data corresponding to the access token """
          oauth_provider = self.env['auth.oauth.provider'].browse(provider)
!         validation = self._auth_oauth_rpc(oauth_provider.validation_endpoint, access_token, provider)
          if validation.get("error"):
              raise Exception(validation['error'])
          if oauth_provider.data_endpoint:
!             data = self._auth_oauth_rpc(oauth_provider.data_endpoint, access_token, provider)
              validation.update(data)
          return validation
diff -c -r -x '*.po' ./views/auth_oauth_views.xml /home/s111403/work/auth_oauth/views/auth_oauth_views.xml
*** ./views/auth_oauth_views.xml2019-03-15 00:52:47.824000000 +0000
--- /home/s111403/work/auth_oauth/views/auth_oauth_views.xml2019-03-14 14:28:01.508000000 +0000
***************
*** 10,15 ****
--- 10,16 ----
                              <field name="name" />
                              <field name="client_id" />
                              <field name="enabled" />
+                             <field name="keycloak" />
                              <field name="body" />
                          </group>
                          <group>
***************
*** 30,35 ****
--- 31,37 ----
                      <field name="name" />
                      <field name="client_id" />
                      <field name="enabled" />
+                     <field name="keycloak" />
                  </tree>
              </field>
          </record>


Avatar
Verwerfen
0
Avatar
Daniel Fourman
Best Answer

On the latest version of odoo and keycloak im getting the following error:


2020-09-21 15:38:59,279 12493 ERROR odoo odoo.addons.auth_oauth.controllers.main: OAuth2: can only concatenate str (not "NoneType") to str

Traceback (most recent call last):

  File "/usr/lib/python3/dist-packages/odoo/addons/auth_oauth/controllers/main.py", line 133, in signin

    credentials = env['res.users'].sudo().auth_oauth(provider, kw)

  File "/usr/lib/python3/dist-packages/odoo/addons/auth_oauth/models/res_users.py", line 96, in auth_oauth

    validation = self._auth_oauth_validate(provider, access_token)

  File "/usr/lib/python3/dist-packages/odoo/addons/auth_oauth_keycloak/models/res_users.py", line 39, in _auth_oauth_validate

    validation = self._auth_oauth_rpc(oauth_provider.validation_endpoint, access_token, provider)

  File "/usr/lib/python3/dist-packages/odoo/addons/auth_oauth_keycloak/models/res_users.py", line 32, in _auth_oauth_rpc

    return requests.get(endpoint, headers={'Authorization': 'bearer ' + access_token}).json()

TypeError: can only concatenate str (not "NoneType") to str

2020-09-21 15:38:59,285 12493 INFO odoo werkzeug: 173.245.52.181 - - [21/Sep/2020 15:38:59] "GET /auth_oauth/signin?error=invalid_request&error_description=Invalid+scopes%3A+False&state={%22d%22%3A+%22odoo%22%2C+%22p%22%3A+6%2C+%22r%22%3A+%22https%253A%252F%252Ferp.f-squared.net%252Fweb%22} HTTP/1.0" 303 - 3 0.007 0.021

It looks like keycloak requires a scope, any suggestions on which scope to use and how to properly configure it?

Avatar
Verwerfen
0
Avatar
Janik Von Rotz
Best Answer

Still workss with Odoo 13! Thanks Hideyuki Otokawa and Karim Gillani :)

Avatar
Verwerfen
0
Avatar
Karim Gillani
Best Answer

i tried what you suggested but I still get access denied.   To confirm, the keycloak settings:

  1. Edit email mapper

  2. update Token Claim Name: user_id

Also, there is no place to put the endpoint "token"?  What settings do you have on keycloak client settings page?

The error is much less but still occurs..

Traceback (most recent call last):

  File "/usr/lib/python3/dist-packages/odoo/addons/auth_oauth/controllers/main.py", line 142, in signin

    credentials = env['res.users'].sudo().auth_oauth(provider, kw)

  File "/usr/lib/python3/dist-packages/odoo/addons/auth_oauth/models/res_users.py", line 96, in auth_oauth

    validation = self._auth_oauth_validate(provider, access_token)

  File "/usr/lib/python3/dist-packages/odoo/addons/auth_oauth/models/res_users.py", line 36, in _auth_oauth_validate

    raise Exception(validation['error'])

Exception: invalid_request

2019-03-15 07:25:38,722 1 INFO db werkzeug: 17x.xx.xx.xx - - [15/Mar/2019 07:25:38] "GET /auth_oauth/signin?state={%22r%22%3A+%22https%253A%252F%252Fxxx.xxx.xx.xx.xx%252Fweb%22%2C+%22p%22%3A+7%2C+%22d%22%3A+%22db%22}&session_state=9e09a4d7-5e1f-4acf-b120-42ed5fc7e200&access_token=eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICI1NXhiZzcyaml6NWQ3cEtkbzdwNFhLdTB2VFA2UXMtemthZzFaY1&token_type=bearer&expires_in=900&not-before-policy=1548956992 HTTP/1.1" 303 - 2 0.002 5.115

 Thank you for your help in this..


9 Kommentare
Avatar
Verwerfen
Avatar
Hideyuki Otokawa
-

You do not have to put the endpoint "token".

This is my keycloak client settings;

- access type is confidential

- standard flow is on

- implicit flow is on

Avatar
Karim Gillani
-
Where did you put the client secret?

Regards

On Mar 15, 2019, at 4:32 AM, Hideyuki Otokawa <otokawa.hideyuki@sharp.co.jp> wrote:

You do not have to put the endpoint "token".

This is my keycloak client settings;

- access type is confidential

- standard flow is on

- implicit flow is on

Sent by Odoo S.A. using Odoo.

Avatar
Hideyuki Otokawa
-

Without using secret, you can sign-in by keycloak.

Avatar
Karim Gillani
-

Is there any other mapping I need to do, like name? I am unsure why mine is still not working albeit closer than before.

Again, thank you for your assistance.

Avatar
Hideyuki Otokawa
-

No. In my investigation of the source codes, the only necessary mapping is email to 'user_id'.

Avatar
Karim Gillani
-

I realized I didn't do the patch. Now that I do, I get this error, any suggestions?

Odoo Server Error

Traceback (most recent call last):

File "/usr/lib/python3/dist-packages/odoo/models.py", line 1108, in _validate_fields

check(self)

File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_ui_view.py", line 351, in _check_xml

self.postprocess_and_fields(view.model, view_doc, view.id)

File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_ui_view.py", line 1095, in postprocess_and_fields

self.raise_view_error(message, view_id)

File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_ui_view.py", line 548, in raise_view_error

raise ValueError(message)

ValueError: Field `keycloak` does not exist

Error context:

View `auth.oauth.provider.form`

[view_id: 547, xml_id: n/a, model: auth.oauth.provider, parent_id: n/a]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 757, in parse

self._tags[rec.tag](rec, de, mode=mode)

File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 662, in _tag_record

record = model.with_context(rec_context)._load_records([data], self.mode == 'update')

File "/usr/lib/python3/dist-packages/odoo/models.py", line 3821, in _load_records

records = self._load_records_create([data['values'] for data in to_create])

File "/usr/lib/python3/dist-packages/odoo/models.py", line 3735, in _load_records_create

return self.create(values)

File "<decorator-gen-32>", line 2, in create

File "/usr/lib/python3/dist-packages/odoo/api.py", line 452, in _model_create_multi

return create(self, arg)

File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_ui_view.py", line 428, in create

return super(View, self).create(vals_list)

File "<decorator-gen-3>", line 2, in create

File "/usr/lib/python3/dist-packages/odoo/api.py", line 452, in _model_create_multi

return create(self, arg)

File "/usr/lib/python3/dist-packages/odoo/models.py", line 3552, in create

fields[0].determine_inverse(batch_recs)

File "/usr/lib/python3/dist-packages/odoo/fields.py", line 1097, in determine_inverse

getattr(records, self.inverse)()

File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_ui_view.py", line 275, in _inverse_arch

view.write(data)

File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_ui_view.py", line 444, in write

return super(View, self).write(self._compute_defaults(vals))

File "/usr/lib/python3/dist-packages/odoo/models.py", line 3269, in write

self._write(store_vals)

File "/usr/lib/python3/dist-packages/odoo/models.py", line 3413, in _write

self._validate_fields(vals)

File "/usr/lib/python3/dist-packages/odoo/models.py", line 1112, in _validate_fields

raise ValidationError("%s\n\n%s" % (_("Error while validating constraint"), tools.ustr(e)))

odoo.exceptions.ValidationError: ('Error while validating constraint\n\nField `keycloak` does not exist\n\nError context:\nView `auth.oauth.provider.form`\n[view_id: 547, xml_id: n/a, model: auth.oauth.provider, parent_id: n/a]', None)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "/usr/lib/python3/dist-packages/odoo/http.py", line 654, in _handle_exception

return super(JsonRequest, self)._handle_exception(exception)

File "/usr/lib/python3/dist-packages/odoo/http.py", line 312, in _handle_exception

raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])

File "/usr/lib/python3/dist-packages/odoo/tools/pycompat.py", line 87, in reraise

raise value

File "/usr/lib/python3/dist-packages/odoo/http.py", line 696, in dispatch

result = self._call_function(**self.params)

File "/usr/lib/python3/dist-packages/odoo/http.py", line 344, in _call_function

return checked_call(self.db, *args, **kwargs)

File "/usr/lib/python3/dist-packages/odoo/service/model.py", line 97, in wrapper

return f(dbname, *args, **kwargs)

File "/usr/lib/python3/dist-packages/odoo/http.py", line 337, in checked_call

result = self.endpoint(*a, **kw)

File "/usr/lib/python3/dist-packages/odoo/http.py", line 939, in __call__

return self.method(*args, **kw)

File "/usr/lib/python3/dist-packages/odoo/http.py", line 517, in response_wrap

response = f(*args, **kw)

File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 966, in call_button

action = self._call_kw(model, method, args, {})

File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 954, in _call_kw

return call_kw(request.env[model], method, args, kwargs)

File "/usr/lib/python3/dist-packages/odoo/api.py", line 749, in call_kw

return _call_kw_multi(method, model, args, kwargs)

File "/usr/lib/python3/dist-packages/odoo/api.py", line 736, in _call_kw_multi

result = method(recs, *args, **kwargs)

File "/usr/lib/python3/dist-packages/odoo/addons/base/models/res_config.py", line 637, in execute

self._install_modules(to_install)

File "/usr/lib/python3/dist-packages/odoo/addons/base/models/res_config.py", line 34, in _install_modules

result = to_install_modules.button_immediate_install()

File "<decorator-gen-61>", line 2, in button_immediate_install

File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_module.py", line 73, in check_and_log

return method(self, *args, **kwargs)

File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_module.py", line 444, in button_immediate_install

return self._button_immediate_function(type(self).button_install)

File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_module.py", line 553, in _button_immediate_function

modules.registry.Registry.new(self._cr.dbname, update_module=True)

File "/usr/lib/python3/dist-packages/odoo/modules/registry.py", line 86, in new

odoo.modules.load_modules(registry._db, force_demo, status, update_module)

File "/usr/lib/python3/dist-packages/odoo/modules/loading.py", line 421, in load_modules

loaded_modules, update_module, models_to_check)

File "/usr/lib/python3/dist-packages/odoo/modules/loading.py", line 313, in load_marked_modules

perform_checks=perform_checks, models_to_check=models_to_check

File "/usr/lib/python3/dist-packages/odoo/modules/loading.py", line 222, in load_module_graph

load_data(cr, idref, mode, kind='data', package=package, report=report)

File "/usr/lib/python3/dist-packages/odoo/modules/loading.py", line 68, in load_data

tools.convert_file(cr, package.name, filename, idref, mode, noupdate, kind, report)

File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 801, in convert_file

convert_xml_import(cr, module, fp, idref, mode, noupdate, report)

File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 864, in convert_xml_import

obj.parse(doc.getroot(), mode=mode)

File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 763, in parse

exc_info[2]

File "/usr/lib/python3/dist-packages/odoo/tools/pycompat.py", line 86, in reraise

raise value.with_traceback(tb)

File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 757, in parse

self._tags[rec.tag](rec, de, mode=mode)

File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 662, in _tag_record

record = model.with_context(rec_context)._load_records([data], self.mode == 'update')

File "/usr/lib/python3/dist-packages/odoo/models.py", line 3821, in _load_records

records = self._load_records_create([data['values'] for data in to_create])

File "/usr/lib/python3/dist-packages/odoo/models.py", line 3735, in _load_records_create

return self.create(values)

File "<decorator-gen-32>", line 2, in create

File "/usr/lib/python3/dist-packages/odoo/api.py", line 452, in _model_create_multi

return create(self, arg)

File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_ui_view.py", line 428, in create

return super(View, self).create(vals_list)

File "<decorator-gen-3>", line 2, in create

File "/usr/lib/python3/dist-packages/odoo/api.py", line 452, in _model_create_multi

return create(self, arg)

File "/usr/lib/python3/dist-packages/odoo/models.py", line 3552, in create

fields[0].determine_inverse(batch_recs)

File "/usr/lib/python3/dist-packages/odoo/fields.py", line 1097, in determine_inverse

getattr(records, self.inverse)()

File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_ui_view.py", line 275, in _inverse_arch

view.write(data)

File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_ui_view.py", line 444, in write

return super(View, self).write(self._compute_defaults(vals))

File "/usr/lib/python3/dist-packages/odoo/models.py", line 3269, in write

self._write(store_vals)

File "/usr/lib/python3/dist-packages/odoo/models.py", line 3413, in _write

self._validate_fields(vals)

File "/usr/lib/python3/dist-packages/odoo/models.py", line 1112, in _validate_fields

raise ValidationError("%s\n\n%s" % (_("Error while validating constraint"), tools.ustr(e)))

odoo.tools.convert.ParseError: "Error while validating constraint

Field `keycloak` does not exist

Error context:

View `auth.oauth.provider.form`

[view_id: 547, xml_id: n/a, model: auth.oauth.provider, parent_id: n/a]

None" while parsing /mnt/extra-addons/auth_oauth/views/auth_oauth_views.xml:3, near

<record id="view_oauth_provider_form" model="ir.ui.view">

<field name="name">auth.oauth.provider.form</field>

<field name="model">auth.oauth.provider</field>

<field name="arch" type="xml">

<form string="arch">

<sheet>

<group>

<field name="name"/>

<field name="client_id"/>

<field name="enabled"/>

<field name="keycloak"/>

<field name="body"/>

</group>

<group>

<field name="auth_endpoint"/>

<field name="scope"/>

<field name="validation_endpoint"/>

<field name="data_endpoint"/>

</group>

</sheet>

</form>

</field>

</record>

Avatar
Karim Gillani
-

A bit further but now I get this error:

odoo.tools.convert.ParseError: "<class 'ValueError'>: "External ID not found in the system: auth_oauth.provider_openerp" while evaluating

"[ref('auth_oauth.provider_openerp')]"" while parsing /mnt/extra-addons/keycloak_oauth/data/auth_oauth_data.xml:34, near

<function model="auth.oauth.provider" name="write">

<value eval="[ref('auth_oauth.provider_openerp')]"/>

<value model="ir.config_parameter" eval="{ 'client_id': obj().env['ir.config_parameter'].get_param('database.uuid'), }"/>

</function>

Avatar
Karim Gillani
-

Ok, I figured it out. I needed to delete the old Oauth and refresh the list then restart. And all is working now.

For others, I ended up copying the auth_oauth folder, updating with the patch mentioned above and placing in /mnt/extra-addons.

Hideyuki Otokawa thank you so much!!!