odoo/odoo#163625

Created by fw-bot
label
odoo-dev:16.0-15.0-recursive_current_website-bso-65wo-fw
head
e86fecc31c18297f4189ebc39650ba250a2b56ab
target
16.0
merged
3 weeks ago by Website, Benoit Socias (bso)
forward-port of
odoo/odoo#162892 DETACHED (conflicts: ('4c26b2551da2068af9cfcd515aa79297690d696b', 'Auto-merging addons/website/models/website.py\nCONFLICT (content): Merge conflict in addons/website/models/website.py\nAuto-merging addons/website/tests/test_get_current_website.py\nCONFLICT (content): Merge conflict in addons/website/tests/test_get_current_website.py\n', '19:58:21.673156 git.c:463 trace: built-in: git cherry-pick 4c26b2551da2068af9cfcd515aa79297690d696b\nerror: could not apply 4c26b2551da2... [FIX] website: neutralize recursion when determining current website\nhint: After resolving the conflicts, mark them with\nhint: "git add/rm <pathspec>", then run\nhint: "git cherry-pick --continue".\nhint: You can instead skip this commit with "git cherry-pick --skip".\nhint: To abort and get back to the state before "git cherry-pick",\nhint: run "git cherry-pick --abort".\n----------\nstatus:\n', ['4c26b2551da2068af9cfcd515aa79297690d696b']) ('4c26b2551da2068af9cfcd515aa79297690d696b', 'Auto-merging addons/website/models/website.py\nCONFLICT (content): Merge conflict in addons/website/models/website.py\nAuto-merging addons/website/tests/test_get_current_website.py\nCONFLICT (content): Merge conflict in addons/website/tests/test_get_current_website.py\n', '19:58:21.673156 git.c:463 trace: built-in: git cherry-pick 4c26b2551da2068af9cfcd515aa79297690d696b\nerror: could not apply 4c26b2551da2... [FIX] website: neutralize recursion when determining current website\nhint: After resolving the conflicts, mark them with\nhint: "git add/rm <pathspec>", then run\nhint: "git cherry-pick --continue".\nhint: You can instead skip this commit with "git cherry-pick --skip".\nhint: To abort and get back to the state before "git cherry-pick",\nhint: run "git cherry-pick --abort".\n----------\nstatus:\n', ['4c26b2551da2068af9cfcd515aa79297690d696b']))

[FW][FIX] website: neutralize recursion when determining current website

If an `ir.rule` about websites involves obtaining the rule's evaluation
context, an infinite recursion happens right after login:
- the `_login` tries to create a `res.users.log` record which needs to
resolve the ACL
- to do this `_eval_context()` is called on `ir.rule`, which in its
`website` module override uses `get_current_website()`
- in turn, this calls `website`'s `_get_current_website_id()` which is
not cached yet
- this involves a `search()` on `website` which needs to resolve the ACL
- to do this `_eval_context()` is again called on `ir.rule`, causing the
loop

This commit prevent this infinite recursion by disabling the ACL check
when determining the current website id in `get_current_website()`,
similarly to what is done in [1] in future versions.

Steps to reproduce:
- Create a rule about `website` with `domain_force` set to
`[(1, '=', 1)]`.
- Log in from an incognito browser.

=> Error 500 because of an infinite recursion.

[1]: https://github.com/odoo/odoo/commit/c68fa610d4e49eedd5f117675b973c551c771e75#diff-5e92e473fa4d3da6db7ef727fb217dad51ef6c2383913edca73fe040a23e82c2R978

task-3884701
opw-3603541

Forward-Port-Of: odoo/odoo#162892