diff options
| author | Romain Derie <rde@odoo.com> | 2019-05-21 10:01:58 +0000 |
|---|---|---|
| committer | Romain Derie <rde@odoo.com> | 2019-05-21 10:01:58 +0000 |
| commit | 90dec44a286c69f31b3fbcf3302f16fdf90d4a5d (patch) | |
| tree | 8bf049d0789e53d1148de23278a477a2e2f9f9c0 /addons/website/models/res_users.py | |
| parent | 7b00776c6c59851a3de3d6e379f354671954d122 (diff) | |
[FIX] website: restore the add of website_id on user at signup
Since b5a12b4aac the website_id was not set anymore.
Indeed, before this commit website_id was the field from the inherits, thus
when writing on website_id from res.user, we would write on the partner field.
But with b5a12b4aac the website_id was explicitely overrided on res.users as a
related to res.partner (its inherits) with readonly=True.
Thus, writting website_id on res.users was not working anymore.
closes odoo/odoo#33521
Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
Diffstat (limited to 'addons/website/models/res_users.py')
| -rw-r--r-- | addons/website/models/res_users.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/addons/website/models/res_users.py b/addons/website/models/res_users.py index a84eaaeb3c6..8902e4c34b6 100644 --- a/addons/website/models/res_users.py +++ b/addons/website/models/res_users.py @@ -2,8 +2,7 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. import logging -from odoo import api, fields, models, tools, _ -from odoo.exceptions import ValidationError +from odoo import api, fields, models, tools from odoo.http import request _logger = logging.getLogger(__name__) @@ -12,8 +11,8 @@ _logger = logging.getLogger(__name__) class ResUsers(models.Model): _inherit = 'res.users' - website_id = fields.Many2one('website', related='partner_id.website_id', store=True, related_sudo=False, readonly=True) - + website_id = fields.Many2one('website', related='partner_id.website_id', store=True, related_sudo=False, readonly=False) + _sql_constraints = [ # Partial constraint, complemented by unique index (see below). Still # useful to keep because it provides a proper error message when a @@ -51,7 +50,7 @@ class ResUsers(models.Model): @api.model_cr_context def _auto_init(self): result = super(ResUsers, self)._auto_init() - # Use unique index to implement unique constraint per website, even if website_id is null + # Use unique index to implement unique constraint per website, even if website_id is null # (not possible using a constraint) tools.create_unique_index(self._cr, 'res_users_login_key_unique_website_index', self._table, ['login', 'COALESCE(website_id,-1)']) |
