Permalink
Browse files

set website value automatically in case 1 company = 1 website

  • Loading branch information...
yelizariev committed Sep 24, 2018
1 parent 34a9886 commit 7cde7d2c8505166752d40bd0ec0cc92bdb83fb7f
Showing with 17 additions and 5 deletions.
  1. +1 −1 web_website/__manifest__.py
  2. +4 −0 web_website/doc/changelog.rst
  3. +12 −4 web_website/models/res_users.py
@@ -6,7 +6,7 @@
"category": "Hidden",
# "live_test_url": "",
"images": [],
"version": "11.0.2.1.4",
"version": "11.0.3.0.0",
"application": False,
"author": "IT-Projects LLC, Ivan Yelizariev",
@@ -1,3 +1,7 @@
`3.0.0`
-------
- **New:** set website value automatically in case 1 company = 1 website
`2.1.4`
-------
- **New:** Computing default company in multi-website environment is moved to
@@ -33,17 +33,25 @@ def _get_company(self):
return self.env['website'].browse(website_id).company_id
return super(ResUsers, self)._get_company()
@api.model
def _search_company_websites(self, company_id):
return self.env['website'].search([
('company_id', 'in', [False] + [company_id])
])
def _compute_backend_website_ids(self):
for r in self:
websites = self.env['website'].search([
('company_id', 'in', [False] + [r.company_id.id])
])
websites = self._search_company_websites(r.company_id.id)
r.backend_website_ids = websites
r.backend_websites_count = len(websites)
def write(self, vals):
if 'company_id' in vals and 'backend_website_id' not in vals:
vals['backend_website_id'] = False
websites = self._search_company_websites(vals['company_id'])
if len(websites) == 1:
vals['backend_website_id'] = websites.id
else:
vals['backend_website_id'] = None
return super(ResUsers, self).write(vals)
@api.onchange('company_id')

0 comments on commit 7cde7d2

Please sign in to comment.