Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
3 Replies
10184 Tampilan

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 !


Avatar
Buang
Penulis Jawaban Terbai

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.

Avatar
Buang
Jawaban Terbai

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

Avatar
Buang
Jawaban Terbai

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

Avatar
Buang
Post Terkait Replies Tampilan Aktivitas
1
Sep 24
1112
0
Agu 24
1338
1
Jun 23
3646
0
Jun 23
1573
1
Jan 25
2260