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

Hello,

We have multiple companies, and we are trying to use private windows to keep sessions apart for these companies.

Is it possible to craft a URL somehow, or maybe issue an API command such that the browser loads a company directly? Right now, when I open a new, private window and log in, the company is always set to the primary/default company. Would it be possible to e.g. open https://odoo.example.org/login?company=7​ or similar, such that after login, the 7th company is already selected?

Thank you,

martin

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

This should work:

http://odoo.example.org/web/login?redirect=/web#cids=7

In case you have multiple databases, you want to add a param for it as well:

http://odoo.example.org/web/login?db=db1&redirect=/web#cids=7

If you want multiple companies to be active, make cids comma-separated, i.e. cids=7,8,9


Note that, apparently, the redirect parameter must not be url encoded!

Ảnh đại diện
Huỷ bỏ
Tác giả

It must be Karma, for now I can comment. A bit silly, but okay.

Thanks for the link to the route. I verified that `redirect` in fact works using `/my` as you suggested. I've tried this on both, Odoo 17 and 18.

I also found that `cids` is just a cookie, and that if I change its value and reload, then a different company is selected. Sometimes the things are much easier than you think, and I didn't need to study all the VoodooScript, lol. Thank you for helping me on this!

Tác giả Câu trả lời hay nhất

When I click the comment button under your post, nothing happens. Thus I am sending a top-level reply. I am sorry…

Hey Christoph, thank you so much for your quick response!

I could not get the suggested URL parameter to work, neither in the single, nor in the multiple version, neither URL-encoded nor verbatim.

Can you point me to where you got this information from, so I can research a bit more, and mess around a bit?

I also looked on the network console and I couldn't even find out what is happening when I use the company selector to change companies. There must be some sort of dark, obscure voodoo magic going on. I don't like it :(.

Ảnh đại diện
Huỷ bỏ
Tác giả

I can reply to my own comment, but the speech bubble below yours is greyed out and I cannot. What gives?

Some call it Voodoo, others call it JavaScript, owl in this case to be more precise. None the less, I feel you on that one... Source is, well, source code; and verification in localhost as well as on odoo.sh. The /web/login route is defined here:
https://github.com/odoo/odoo/blob/18.0/addons/web/controllers/home.py#L97 and 'cids' is commonly used throughout those voodoo-files to refer to company_ids. Now, I should mention, that a test in demo.odoo.com did in fact not succeed - which can be due to 18.3 working just that bit differently, or, what I would assume more, the cookies stored on that session are messing with the known default company. In any case, you may actually want to try to clear your browser cookies unless you're operating incognito already. What version of Odoo are you running exactly?
Also, to verify your redirect aren't completely broken for what ever reason, you can try to test a redirect to a portal page, such as /my upon login as well.
And, about commenting: https://www.odoo.com/forum/1/faq/karma - I would assume 1k is the threshold but I have honestly no clue.

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 4 21
4202
0
thg 4 25
1032
0
thg 2 24
816
0
thg 10 18
6388
0
thg 3 15
4014