This question has been flagged
1 Reply
2307 Views

Version: Odoo 14.0

How can I create a public route to access stock data without login authentication?

@http.route('/nuanju/stock_report', auth='public', website=True, methods=['GET']) For this request, I'm getting this error :

odoo.exceptions.AccessError: You are not allowed to access 'Quants' (stock.quant) records.

This operation is allowed for the following groups:

- Inventory/Administrator

- Inventory/User

- User types/Internal User

Contact your administrator to request access if necessary.

I have also one public user in database


Avatar
Discard
Best Answer

Your route is already working but the issue is with the access rights since the user is not logged-in.

Either add access rights to the objects you are trying to access for a public user or use "sudo" in your code to bypass the access rights.

request.env['stock.quant'].sudo().search([])


Avatar
Discard
Author

Now it works. Thanks!