-
-
Notifications
You must be signed in to change notification settings - Fork 585
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
⚡ different template users for each website #993
Open
KolushovAlexandr
wants to merge
1
commit into
itpp-labs:11.0
Choose a base branch
from
KolushovAlexandr:11.0-web_website-template_user
base: 11.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
# Copyright 2018 Ivan Yelizariev <https://it-projects.info/team/yelizariev> | ||
# Copyright 2020 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr> | ||
# License MIT (https://opensource.org/licenses/MIT). | ||
{ | ||
"name": """Website Switcher in Backend""", | ||
"summary": """Technical module to switch Websites in Backend similarly to Company Switcher""", | ||
"category": "Hidden", | ||
# "live_test_url": "", | ||
"images": [], | ||
"version": "11.0.3.0.4", | ||
"version": "11.0.3.1.0", | ||
"application": False, | ||
"author": "IT-Projects LLC, Ivan Yelizariev", | ||
"support": "[email protected]", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ | |
from . import res_config | ||
from . import res_users | ||
from . import ir_http | ||
from . import website |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Copyright 2020 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr> | ||
# License MIT (https://opensource.org/licenses/MIT). | ||
|
||
from odoo import api, models | ||
|
||
|
||
class Website(models.Model): | ||
_inherit = "website" | ||
|
||
@api.model | ||
def create(self, vals): | ||
website = super(Website, self).create(vals) | ||
website.create_new_template_user_id() | ||
return website | ||
|
||
@api.multi | ||
def create_new_template_user_id(self): | ||
IrConfigParameter = self.env["ir.config_parameter"].sudo() | ||
user_id = IrConfigParameter.get_param("auth_signup.template_user_id", "False") | ||
user_id = self.env["res.users"].sudo().browse(user_id and int(user_id)) | ||
for record in self: | ||
company_id = record.company_id.id | ||
new_user_id = user_id.sudo().copy( | ||
{ | ||
"login": "{} - {}".format(user_id.login, record.name), | ||
"company_id": company_id, | ||
"company_ids": [(6, 0, [company_id])], | ||
"backend_website_ids": [(6, 0, record.ids)], | ||
} | ||
) | ||
IrConfigParameter.with_context(dict(website_id=record.id)).set_param( | ||
"auth_signup.template_user_id", new_user_id.id | ||
) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
auth_signup is not in depedencies of web_website module
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you're right, forgot to test this case. Website module is in dependencies and it uses such structures but they won't lead to an error.
https://github.com/odoo/odoo/blob/11.0/addons/website/models/res_config_settings.py#L94
Should i do a new auth_signup_multi_website module then? It is a more general approach and allows to use built-in methods
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new module auth_signup_multi_website should be fine.
FYI: odoo 13 already support this feature