Skip to content

Commit 670f43c

Browse files
committed
[FIX] webservice: WARNING message in logs
The use of a compute method on `oauth2_flow` when this field is touched by the server environment mixin causes it to be defined twice as computed, with differents settings, and this ultimately causes a warning message in the logs: ``` WARNING odoo odoo.modules.registry: webservice.backend: inconsistent 'compute_sudo' for computed fields: protocol, url, auth_type, username, password, api_key, api_key_header, oauth2_flow, oauth2_clientid, oauth2_client_secret, oauth2_token_url, oauth2_authorization_url, oauth2_audience, oauth2_scope, content_type ``` We fix this by using an old fashioned onchange declaration on the `auth_type` field.
1 parent 918b954 commit 670f43c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

webservice/models/webservice_backend.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ class WebserviceBackend(models.Model):
4040
],
4141
readonly=False,
4242
store=True,
43-
compute="_compute_oauth2_flow",
4443
)
4544
oauth2_clientid = fields.Char(string="Client ID", auth_type="oauth2")
4645
oauth2_client_secret = fields.Char(string="Client Secret", auth_type="oauth2")
@@ -122,8 +121,10 @@ def _get_adapter_protocol(self):
122121
protocol += f"+{self.auth_type}-{self.oauth2_flow}"
123122
return protocol
124123

125-
@api.depends("auth_type")
126-
def _compute_oauth2_flow(self):
124+
@api.onchange("auth_type")
125+
def _onchange_oauth2_auth_type(self):
126+
# reset the auth2_flow when auth_type is not oaut2
127+
# using a compute method interfers with the server environment mixin
127128
for rec in self:
128129
if rec.auth_type != "oauth2":
129130
rec.oauth2_flow = False

0 commit comments

Comments
 (0)