Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
3 Trả lời
10292 Lượt xem

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 !


Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

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.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 9 24
1160
0
thg 8 24
1416
1
thg 6 23
3717
0
thg 6 23
1633
1
thg 1 25
2330