تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
1271 أدوات العرض

I want to give the public user access to some data.


But if I use the jsonRPC without credentials I always get a Odoo Session Expired although the permissions would allow my model to be read from a public user.



What can I do to receive data as a public user?

الصورة الرمزية
إهمال
الكاتب أفضل إجابة

But I want to make my question more precise:

Is it possible to the this jsonrpc working with a session_id of a public user? (not logged in)




import requests

import json


url = "https://73515246-18-0-all.runbot185.odoo.com/web/dataset/call_kw/forum.post/web_search_read"


payload = json.dumps({

"id": 1,

"jsonrpc": "2.0",

"method": "call",

"params": {

"model": "res.partner",

"method": "web_search_read",

"args": [],

"kwargs": {

"specification": {

"name": {}

},

"order": "name",

"domain": [],

"context": {

"uid": None

}

}

}

})

headers = {

'Content-Type': 'application/json',

'Cookie': 'session_id=clfQpy5iv6hb5cq9VacECtum8t2bPZ1OhBwZ5AEr9ya_4xj-I84eUSrEJKSOLhCy9JcXhpOq8QSmusQ3S08M'

}


response = requests.request("GET", url, headers=headers, data=payload)


print(response.text)


الصورة الرمزية
إهمال
أفضل إجابة

Just create a publicly accessible controller and use as any REST.
For example, the below GET endpoint can be accessed by just visiting /thank_you.

from odoo import http

class ThankYouController(http.Controller):

​@http.route('/thank_you', auth='public', methods=['GET'], type='http')

​def thank_you(self, **kwargs):

​return "THANK YOU"

الصورة الرمزية
إهمال
الكاتب

Thanks, but the background I need this is because I want to use websearchread an standard OWL method to retrieve data. But If the user is not logged in it does not work. I want to use Owl2 in the frontend which works perfectly with websearchread but as it's also can be used by not logged in users it also has to work with not logged in users.
The core problem can be replicated by creating a json request without authentication. It would be interesting if there is standard way to do this. I had to override some very basic functionality which I want to avoid.

المنشورات ذات الصلة الردود أدوات العرض النشاط
0
مارس 24
874
2
سبتمبر 15
6276
1
أبريل 23
2814
2
يوليو 25
1413
0
يوليو 25
328