yezyilomo / odoo-rest-api

Module which expose Odoo as a REST API
MIT License
202 stars 162 forks source link

Only first record in response #47

Closed iiram closed 4 years ago

iiram commented 4 years ago

Hello, and thanks for this api!

I'm a beginner with odoo and I probably have something wrong with my approach when I try to get a listing of warehouse locations and their product saldos. The model in question is stock.quant and the problem is that even though the response has the count of records right (in my case 66), details for only the first record is in the response, for all the other details there are just empty rows {}, {},...

I'm testing this with the postman with the url as http://192.168.0.63:8040/api/stock.quant/?session_id=be17cdfa61261f24e7f18e921d8f3c84e0b326d0 and the response payload is { "count": 66, "prev": null, "current": 1, "next": null, "total_pages": 1, "result": [ { "__last_update": "2020-06-06-08-05", "write_date": "2020-06-06-08-05", "write_uid": 1, "create_date": "2020-06-06-08-05", "create_uid": 1, "display_name": "[FURN_0789] Individual Workplace", "id": 1, "currency_id": 1, "value": 0.0, "on_hand": false, "tracking": "none", "in_date": "2020-06-06-08-06", "reserved_quantity": 0.0, "inventory_quantity": 0.0, "quantity": -16.0, "owner_id": false, "package_id": false, "lot_id": false, "location_id": 14, "company_id": 1, "product_uom_id": 1, "product_tmpl_id": 22, "product_id": 30 }, {}, {}, ...

What am I doing wrong? Is there a way to somehow get all the records listed with the details.

Many thanks in advance iiram

yezyilomo commented 4 years ago

Yeah this looks like a bug, for the mean time if you use ?query={field1, field1, ...} parameter you get all fields included.

yezyilomo commented 4 years ago

Got it, this is the one causing it https://github.com/yezyilomo/odoo-rest-api/blob/2706c15de7425d24bb156d75f9b48c813eeefae7/controllers/serializers.py#L132-L137 reversed returns a generator which generates items only once, so only the first iteration of the for loop below it has access to the generated items the rest gets empty generator.

jeffery9 commented 3 years ago

this Pr is worked.