Skip to content

Commit

Permalink
helpdesk: adapat return to WrappedList
Browse files Browse the repository at this point in the history
we need to return {data:[ records ]} instead of records directly

needs https://github.com/OCA/rest-framework/pull/307/commits
  • Loading branch information
hparfr committed Mar 18, 2024
1 parent 9e0cbc5 commit 286a34f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions shopinvader_helpdesk/services/ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
from odoo.exceptions import UserError

from odoo.addons.base_rest import restapi
from odoo.addons.base_rest_pydantic.restapi import PydanticModel, PydanticModelList
from odoo.addons.base_rest_pydantic.restapi import PydanticModel
from odoo.addons.base_rest_pydantic.pydantic_models.wrapped import WrappedList
from odoo.addons.component.core import Component

from ..pydantic_models.ticket import (
Expand Down Expand Up @@ -36,14 +37,15 @@ def get(self, _id):
@restapi.method(
routes=[(["/"], "GET")],
input_param={},
output_param=PydanticModelList(HelpdeskTicketInfo),
output_param=PydanticModel(WrappedList[HelpdeskTicketInfo]),
)
def search(self):
results = super().search()
infos = [
HelpdeskTicketInfo.from_orm(self.env[self._expose_model].browse(item.id))
for item in super().search()
for item in results.data
]
return infos
return WrappedList(data=infos)

@restapi.method(
routes=[(["/create"], "POST")],
Expand Down

0 comments on commit 286a34f

Please sign in to comment.