Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Odoo CE
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Coopdevs
Comunitats Energètiques
Odoo CE
Commits
09a7dd01
Commit
09a7dd01
authored
2 years ago
by
Xavier Bonet
Browse files
Options
Downloads
Patches
Plain Diff
ADD keycloak group to new users created from odoo
parent
89264ab6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!5
ADD keycloak group to new users created from odoo
Pipeline
#13400
passed with warnings
2 years ago
Stage: test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
ce/models/__init__.py
+1
-0
1 addition, 0 deletions
ce/models/__init__.py
ce/models/auth_keycloak_create_wiz.py
+26
-0
26 additions, 0 deletions
ce/models/auth_keycloak_create_wiz.py
ce/models/res_users.py
+8
-0
8 additions, 0 deletions
ce/models/res_users.py
with
35 additions
and
0 deletions
ce/models/__init__.py
+
1
−
0
View file @
09a7dd01
...
...
@@ -6,4 +6,5 @@ from . import res_partner
from
.
import
subscription_request
from
.
import
res_users
from
.
import
account_invoice
from
.
import
auth_keycloak_create_wiz
This diff is collapsed.
Click to expand it.
ce/models/auth_keycloak_create_wiz.py
0 → 100644
+
26
−
0
View file @
09a7dd01
from
odoo
import
fields
,
models
,
api
class
KeycloakCreateWiz
(
models
.
TransientModel
):
"""
Export Odoo users to Keycloak.
Usually Keycloak is already populated w/ your users base.
Many times this will come via LDAP, AD, pick yours.
Still, you might need to push some users to Keycloak on demand,
maybe just for testing.
If you need this, this is the wizard for you ;)
"""
_inherit
=
'
auth.keycloak.create.wiz
'
def
_create_user_values
(
self
,
odoo_user
):
"""
Prepare Keycloak values for given Odoo user.
"""
values
=
super
(
KeycloakCreateWiz
,
self
).
_create_user_values
(
odoo_user
)
if
self
.
_context
.
get
(
'
kc_user_creation_vals
'
):
values
.
update
(
self
.
_context
.
get
(
'
kc_user_creation_vals
'
))
return
values
This diff is collapsed.
Click to expand it.
ce/models/res_users.py
+
8
−
0
View file @
09a7dd01
...
...
@@ -10,6 +10,7 @@ class ResUsers(models.Model):
def
push_new_user_to_keyckoack
(
self
):
self
.
ensure_one
()
ICPSudo
=
self
.
env
[
'
ir.config_parameter
'
].
sudo
()
ce_admin_provider
=
self
.
company_id
.
ce_admin_key_cloak_provider_id
if
not
ce_admin_provider
:
...
...
@@ -23,5 +24,12 @@ class ResUsers(models.Model):
'
pwd
'
:
ce_admin_provider
.
superuser_pwd
,
'
login_match_key
'
:
'
username:login
'
}
ck_user_group_mapped_to_odoo_group_ce_member
=
ICPSudo
.
get_param
(
'
ce.ck_user_group_mapped_to_odoo_group_ce_admin
'
)
kc_user_additional_vals
=
{
'
attributes
'
:{
'
lang
'
:[
self
.
lang
]},
'
groups
'
:
[
ck_user_group_mapped_to_odoo_group_ce_member
],
}
self
=
self
.
with_context
(
kc_user_creation_vals
=
kc_user_additional_vals
)
wiz
=
self
.
env
[
'
auth.keycloak.create.wiz
'
].
create
(
wiz_vals
)
wiz
.
button_create_user
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment