Skip to content

Commit 8ee2825

Browse files
authored
Merge pull request #995 from em230418/11.0-web_website-uid-fix
[11.0] web_website: fix _get_website_id wrongly returning SUPERUSER_ID's website
2 parents aca1455 + 5bf2720 commit 8ee2825

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

web_website/README.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ Roadmap
3838
* TODO: Use context on switching between websites to allow work with different
3939
websites at the same time by using different browser tabs. It also fixes
4040
problem of using superuser's configuration when ``sudo()`` is used.
41+
This is partly fixed by checking context's uid in ``_get_website_id`` method.
4142

4243
Credits
4344
=======
@@ -55,7 +56,7 @@ Maintainers
5556
* `IT-Projects LLC <https://it-projects.info>`__
5657

5758
To get a guaranteed support
58-
you are kindly requested to purchase the module
59+
you are kindly requested to purchase the module
5960
at `odoo apps store <https://apps.odoo.com/apps/modules/11.0/web_website/>`__.
6061

6162
Thank you for understanding!

web_website/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"category": "Hidden",
77
# "live_test_url": "",
88
"images": [],
9-
"version": "11.0.3.0.4",
9+
"version": "11.0.3.0.5",
1010
"application": False,
1111
"author": "IT-Projects LLC, Ivan Yelizariev",
1212
"support": "[email protected]",

web_website/doc/changelog.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
`3.0.5`
2+
-------
3+
- **Fix:** _get_website_id could return SUPERUSER_ID's website instead of current user
4+
15
`3.0.4`
26
-------
37
- **Fix:** Incorrect return data in get_multi in case of 'many2one' field, id instead of a record

web_website/models/ir_property.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,15 @@ def _check_website_dependent(self, name, model, **kwargs):
4747

4848
@api.model
4949
def _get_website_id(self):
50-
website_id = (
51-
self._context.get("website_id") or self.env.user.backend_website_id.id
52-
)
53-
return website_id
50+
if self._context.get("website_id"):
51+
return self._context.get("website_id")
52+
53+
if self._context.get("uid"):
54+
user = self.env["res.users"].browse(self._context["uid"])
55+
else:
56+
user = self.env.user
57+
58+
return user.backend_website_id.id
5459

5560
def _get_domain(self, prop_name, model):
5661
domain = super(IrProperty, self)._get_domain(prop_name, model)

0 commit comments

Comments
 (0)