Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
3 Antworten
10267 Ansichten

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
Verwerfen
Autor Beste Antwort

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
Verwerfen
Beste Antwort

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
Verwerfen
Beste Antwort

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
Verwerfen
Verknüpfte Beiträge Antworten Ansichten Aktivität
1
Sept. 24
1148
0
Aug. 24
1398
1
Juni 23
3705
0
Juni 23
1628
1
Jan. 25
2314