Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
3 Відповіді
10386 Переглядів

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

Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
1
вер. 24
1231
0
серп. 24
1512
1
черв. 23
3835
0
черв. 23
1700
1
січ. 25
2368