-
-
Notifications
You must be signed in to change notification settings - Fork 585
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
⚡ different template users for each website
- Loading branch information
1 parent
63a51a9
commit 3f94df0
Showing
5 changed files
with
66 additions
and
2 deletions.
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,31 @@ | ||
# 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) |