[IMP] res_lang: don't allow unactivating of a used language
Unactivating the preferred language of a user will prevent him from logging in.
This commit is contained in:
committed by
Antony Lesuisse
parent
60af9986ed
commit
a0857f13eb
@@ -176,6 +176,17 @@ class lang(osv.osv):
|
||||
return grouping, thousands_sep, decimal_point
|
||||
|
||||
def write(self, cr, uid, ids, vals, context=None):
|
||||
if isinstance(ids, (int, long)):
|
||||
ids = [ids]
|
||||
|
||||
if vals.get('active') == False:
|
||||
users = self.pool.get('res.users')
|
||||
|
||||
for current_id in ids:
|
||||
current_language = self.browse(cr, uid, current_id, context=context)
|
||||
if users.search(cr, uid, [('lang', '=', current_language.code)], context=context):
|
||||
raise UserError(_("Cannot unactivate a language that is currently used by users."))
|
||||
|
||||
self._lang_get.clear_cache(self)
|
||||
self._lang_data_get.clear_cache(self)
|
||||
return super(lang, self).write(cr, uid, ids, vals, context)
|
||||
|
||||
Reference in New Issue
Block a user