Skip to content

Commit

Permalink
Merge pull request #995 from em230418/11.0-web_website-uid-fix
Browse files Browse the repository at this point in the history
[11.0] web_website: fix _get_website_id wrongly returning SUPERUSER_ID's website
  • Loading branch information
trojikman authored Aug 24, 2020
2 parents aca1455 + 5bf2720 commit 8ee2825
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
3 changes: 2 additions & 1 deletion web_website/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Roadmap
* TODO: Use context on switching between websites to allow work with different
websites at the same time by using different browser tabs. It also fixes
problem of using superuser's configuration when ``sudo()`` is used.
This is partly fixed by checking context's uid in ``_get_website_id`` method.

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

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

Thank you for understanding!
Expand Down
2 changes: 1 addition & 1 deletion web_website/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"category": "Hidden",
# "live_test_url": "",
"images": [],
"version": "11.0.3.0.4",
"version": "11.0.3.0.5",
"application": False,
"author": "IT-Projects LLC, Ivan Yelizariev",
"support": "[email protected]",
Expand Down
4 changes: 4 additions & 0 deletions web_website/doc/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
`3.0.5`
-------
- **Fix:** _get_website_id could return SUPERUSER_ID's website instead of current user

`3.0.4`
-------
- **Fix:** Incorrect return data in get_multi in case of 'many2one' field, id instead of a record
Expand Down
13 changes: 9 additions & 4 deletions web_website/models/ir_property.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,15 @@ def _check_website_dependent(self, name, model, **kwargs):

@api.model
def _get_website_id(self):
website_id = (
self._context.get("website_id") or self.env.user.backend_website_id.id
)
return website_id
if self._context.get("website_id"):
return self._context.get("website_id")

if self._context.get("uid"):
user = self.env["res.users"].browse(self._context["uid"])
else:
user = self.env.user

return user.backend_website_id.id

def _get_domain(self, prop_name, model):
domain = super(IrProperty, self)._get_domain(prop_name, model)
Expand Down

0 comments on commit 8ee2825

Please sign in to comment.