Skip to content
Browse files

[IMP] website: cannot deactivate language if set in language_ids for …


closes #31520

Signed-off-by: Jérémy Kersten (jke) <>
  • Loading branch information...
pla-odoo committed Jan 21, 2019
1 parent ea70cb2 commit 8e2f9a4fe202ec759c6196af14802ae591c66a63
@@ -18,3 +18,4 @@
from . import res_partner
from . import res_users
from . import res_config_settings
from . import res_lang
@@ -18,7 +18,7 @@ def _default_website(self):
website_domain = fields.Char('Website Domain', related='website_id.domain', readonly=False)
website_country_group_ids = fields.Many2many(related='website_id.country_group_ids', readonly=False)
website_company_id = fields.Many2one(related='website_id.company_id', string='Website Company', readonly=False)
language_ids = fields.Many2many(related='website_id.language_ids', relation='res.lang', readonly=False)
language_ids = fields.Many2many(related='website_id.language_ids', relation='res.lang', readonly=False, required=True)
language_count = fields.Integer(string='Number of languages', compute='_compute_language_count', readonly=True)
website_default_lang_id = fields.Many2one(
string='Default language', related='website_id.default_lang_id', readonly=False,
@@ -106,7 +106,9 @@ def inverse_has_google_analytics_dashboard(self):
def _onchange_language_ids(self):
# If current default language is removed from language_ids
# update the website_default_lang_id
if self.language_ids and self.website_default_lang_id not in self.language_ids:
if not self.language_ids:
self.website_default_lang_id = False
elif self.website_default_lang_id not in self.language_ids:
self.website_default_lang_id = self.language_ids[0]

@@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from odoo import api, models, _
from odoo.exceptions import UserError

class Lang(models.Model):
_inherit = "res.lang"

def write(self, vals):
if 'active' in vals and not vals['active']:
if self.env['website'].search([('language_ids', 'in', self._ids)]):
raise UserError(_("Cannot deactivate a language that is currently used on a website."))
return super(Lang, self).write(vals)

0 comments on commit 8e2f9a4

Please sign in to comment.
You can’t perform that action at this time.