Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions oauth_provider/models/oauth_provider_scope.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link

Copilot AI Jan 12, 2026

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".

Suggested change
# m2o filds return a tuple (id, name), now we want keep it
# m2o fields return a tuple (id, name), now we want keep it

Copilot uses AI. Check for mistakes.
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
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented-out code should be removed entirely rather than left in the codebase. If the old implementation needs to be referenced, it can be retrieved from version control history.

Suggested change
# 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 uses AI. Check for mistakes.

Comment on lines +83 to 90
Copy link

Copilot AI Jan 12, 2026

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.

Suggested change
# 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

Copilot uses AI. Check for mistakes.
# Keep a list of records that match all scopes
if all_scopes_records is None:
Expand Down
Loading