跳至內容
選單
此問題已被標幟
3 回覆
10187 瀏覽次數

Hi ! I'm on Odoo (v8).

I have a custom web page that create a custom product. The form point to the /shop/cart/update route of the website_sale module.

When I'm not logged in (visitor), I have this error in the JS console:


"Server application error" Object { message: "Odoo Session Expired", code: 100, data: Object }

declare/genericJsonRpc/result<()

.Deferred/promise.then/</</<()

jQuery.Callbacks/fire()

jQuery.Callbacks/self.fireWith()

done()

.send/callback()


I suppose that a user must at least log in as portal user to add products to their carts.

But then, if I use the shop defined by the same website_sale module, by adding products to the cart, that work, even as a visitor !


How they manage to do that ? I can't figure out by viewing the code.

thanks for the help !


頭像
捨棄
作者 最佳答案

I think I got it. I still have to try this out but, we'll se.

In fact, I just had to look closer to the js files of the website_sale module. Their JS code is doing json requests on the controller's functions. My JS code was doing json request on my models.Model's functions. And because Model have access rights, I think that's why visitors couldn't trigger my json calls.

I will confirm this if I get this to work.

Update:

I have an issue that I will cover myself or ask in another thread. But this is the solution.

頭像
捨棄
最佳答案

Thank you @PY and @Axel Mendoza, I was facing the same problem, which Odoo keeps notifying me with session expiration when I'm not logged in (a visitor). The reason was requesting a model in my JS code. I did replace it with requesting a controller, and it's gone.

Note: I'm using Odoo 16

頭像
捨棄
最佳答案

Because of you are firing request against your models functions you need a db parameter setted in you OpenERPSession at the server side, this only get setted when you login ok, if you are not logged you dont have a db setted in your session and any call for using models for Odoo seems that your session have expired

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
1
9月 24
1114
0
8月 24
1340
1
6月 23
3647
0
6月 23
1575
1
1月 25
2261