Skip to content

Commit 3b4ad04

Browse files
committed
[MIG] oauth_provider: Migration to 19.0
1 parent 93c54e5 commit 3b4ad04

File tree

7 files changed

+26
-38
lines changed

7 files changed

+26
-38
lines changed

oauth_provider/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{
55
"name": "OAuth Provider",
66
"summary": "Allows to use Odoo as an OAuth2 provider",
7-
"version": "18.0.1.0.0",
7+
"version": "19.0.1.0.0",
88
"category": "Authentication",
99
"website": "https://github.com/OCA/server-auth",
1010
"author": "SYLEAM, Odoo Community Association (OCA)",

oauth_provider/models/oauth_provider_authorization_code.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,7 @@ class OAuthProviderAuthorizationCode(models.Model):
3737
default=True, help="When unchecked, the code is invalidated."
3838
)
3939

40-
_sql_constraints = [
41-
(
42-
"code_client_id_unique",
43-
"UNIQUE (code, client_id)",
44-
"The authorization code must be unique per client !",
45-
),
46-
]
40+
_code_client_id_unique = models.Constraint(
41+
"UNIQUE (code, client_id)",
42+
"The authorization code must be unique per client !",
43+
)

oauth_provider/models/oauth_provider_client.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,10 @@ class OAuthProviderClient(models.Model):
102102
# rfc6749/grant_types/authorization_code.py#L471-L474
103103
client_id = fields.Char(compute="_compute_oauthlib_client_id")
104104

105-
_sql_constraints = [
106-
(
107-
"identifier_unique",
108-
"UNIQUE (identifier)",
109-
"The identifier of the client must be unique !",
110-
),
111-
]
105+
_identifier_unique = models.Constraint(
106+
"UNIQUE (identifier)",
107+
"The identifier of the client must be unique !",
108+
)
112109

113110
@api.model
114111
def application_type_mapping(self):

oauth_provider/models/oauth_provider_scope.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,10 @@ class OAuthProviderScope(models.Model):
4646
help="Fields allowed by this scope.",
4747
)
4848

49-
_sql_constraints = [
50-
("code_unique", "UNIQUE (code)", "The code of the scopes must be unique !"),
51-
]
49+
_code_unique = models.Constraint(
50+
"UNIQUE (code)",
51+
"The code of the scopes must be unique !",
52+
)
5253

5354
@api.model
5455
def _get_ir_filter_eval_context(self):

oauth_provider/models/oauth_provider_token.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,14 @@ class OAuthProviderToken(models.Model):
4242
help="A token is active only if it has not yet expired.",
4343
)
4444

45-
_sql_constraints = [
46-
(
47-
"token_unique",
48-
"UNIQUE (token, client_id)",
49-
"The token must be unique per client !",
50-
),
51-
(
52-
"refresh_token_unique",
53-
"UNIQUE (refresh_token, client_id)",
54-
"The refresh token must be unique per client !",
55-
),
56-
]
45+
_token_unique = models.Constraint(
46+
"UNIQUE (token, client_id)",
47+
"The token must be unique per client !",
48+
)
49+
_refresh_token_unique = models.Constraint(
50+
"UNIQUE (refresh_token, client_id)",
51+
"The refresh token must be unique per client !",
52+
)
5753

5854
@api.depends("expires_at")
5955
def _compute_active(self):

oauth_provider/models/res_users.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@ class ResUsers(models.Model):
1818
help="String used to identify this user during an OAuth session.",
1919
)
2020

21-
_sql_constraints = [
22-
(
23-
"oauth_identifier_unique",
24-
"UNIQUE (oauth_identifier)",
25-
"The OAuth identifier of the user must be unique !",
26-
),
27-
]
21+
_oauth_identifier_unique = models.Constraint(
22+
"UNIQUE (oauth_identifier)",
23+
"The OAuth identifier of the user must be unique !",
24+
)

oauth_provider/security/oauth_provider_security.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
</record>
1010

1111
<record id="base.user_admin" model="res.users">
12-
<field name="groups_id" eval="[(4, ref('group_oauth_provider_manager'))]" />
12+
<field name="group_ids" eval="[(4, ref('group_oauth_provider_manager'))]" />
1313
</record>
1414
</odoo>

0 commit comments

Comments
 (0)