Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[IMP] website: cannot deactivate language if set in language_ids for …
…website closes #31520 Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
- Loading branch information
Showing
3 changed files
with
21 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 |
---|---|---|
|
@@ -18,3 +18,4 @@ | |
from . import res_partner | ||
from . import res_users | ||
from . import res_config_settings | ||
from . import res_lang |
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,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" | ||
|
||
@api.multi | ||
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) |