-
Notifications
You must be signed in to change notification settings - Fork 0
[FIX] oauth_provider: keep tuple #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -80,11 +80,13 @@ def _get_data_for_model(self, model, user, res_id=None, all_scopes_match=False): | |||||||||||||||||||||||||||
| records = self.env[model].with_user(user).search(filter_domain) | ||||||||||||||||||||||||||||
| for record_data in records.read(scope.field_ids.mapped("name")): | ||||||||||||||||||||||||||||
| for field, value in record_data.items(): | ||||||||||||||||||||||||||||
| if isinstance(value, tuple): | ||||||||||||||||||||||||||||
| # Return only the name for a many2one | ||||||||||||||||||||||||||||
| data[record_data["id"]][field] = value[1] | ||||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||||
| data[record_data["id"]][field] = value | ||||||||||||||||||||||||||||
| # m2o filds return a tuple (id, name), now we want keep it | ||||||||||||||||||||||||||||
| data[record_data["id"]][field] = value | ||||||||||||||||||||||||||||
| # if isinstance(value, tuple): | ||||||||||||||||||||||||||||
| # # Return only the name for a many2one | ||||||||||||||||||||||||||||
| # data[record_data["id"]][field] = value[1] | ||||||||||||||||||||||||||||
| # else: | ||||||||||||||||||||||||||||
| # data[record_data["id"]][field] = value | ||||||||||||||||||||||||||||
|
Comment on lines
+85
to
+89
|
||||||||||||||||||||||||||||
| # if isinstance(value, tuple): | |
| # # Return only the name for a many2one | |
| # data[record_data["id"]][field] = value[1] | |
| # else: | |
| # data[record_data["id"]][field] = value |
Copilot
AI
Jan 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change will cause a critical bug. The data returned by this method is serialized to JSON in the controller using json.dumps() (see ir_http.py:45). Python tuples are not JSON serializable, which will cause a TypeError at runtime when many2one fields are included in the response.
Additionally, this is a breaking API change. The existing tests expect many2one fields to return just the name string (see test_oauth_provider_scope.py:222 which expects "country_id": country.name), not a tuple.
The previous behavior of extracting only the name from the tuple was correct and should be kept.
| # m2o filds return a tuple (id, name), now we want keep it | |
| data[record_data["id"]][field] = value | |
| # if isinstance(value, tuple): | |
| # # Return only the name for a many2one | |
| # data[record_data["id"]][field] = value[1] | |
| # else: | |
| # data[record_data["id"]][field] = value | |
| # m2o fields return a tuple (id, name); return only the name | |
| if isinstance(value, tuple): | |
| # Return only the name for a many2one | |
| data[record_data["id"]][field] = value[1] | |
| else: | |
| data[record_data["id"]][field] = value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spelling error: "filds" should be "fields".