-
-
Notifications
You must be signed in to change notification settings - Fork 284
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[18.0][MIG] partner_multi_company: Migration to 18.0
- Loading branch information
1 parent
895442f
commit bf6c495
Showing
3 changed files
with
45 additions
and
0 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,2 +1,3 @@ | ||
from . import res_company | ||
from . import res_partner | ||
from . import res_users |
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,23 @@ | ||
from odoo import Command, api, models | ||
|
||
|
||
class ResCompany(models.Model): | ||
_inherit = "res.company" | ||
|
||
@api.model_create_multi | ||
def create(self, vals_list): | ||
companies = super().create(vals_list) | ||
for company in companies: | ||
for user in company.user_ids: | ||
if company not in user.partner_id.company_ids: | ||
user.partner_id.company_ids = [Command.link(company.id)] | ||
return companies | ||
|
||
def write(self, vals): | ||
res = super().write(vals) | ||
if "user_ids" in vals: | ||
for company in self.sudo(): | ||
for user in company.user_ids: | ||
if company not in user.partner_id.company_ids: | ||
user.partner_id.company_ids = [Command.link(company.id)] | ||
return res |
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