How to NOT allow user to change his language

35 views
Skip to first unread message

Khurram Shahzad

unread,
Feb 12, 2017, 6:10:10 PM2/12/17
to tryton
Dear All,

The user can change his language from User -> Preferences -> Language. How can we restrict user so that he/she can not change his language from user menu.

I have tried to add a record in Administration -> User Interface -> Models -> Model Access -> Field Access for 'language' field in res_user with 'read' access. But, even then the user can log in and change his language using User -> Preference menu.

Thanking in anticipation.

Regards,
Khurram.

Cédric Krier

unread,
Feb 12, 2017, 6:30:07 PM2/12/17
to tryton
There is not check access done when user set its preferences because it
is his preferences (and also because only administrator has write access
on res.user). So setting access on res.user does not change anything.

--
Cédric Krier - B2CK SPRL
Email/Jabber: cedric...@b2ck.com
Tel: +32 472 54 46 59
Website: http://www.b2ck.com/

Cédric Krier

unread,
Feb 12, 2017, 6:40:06 PM2/12/17
to tryton
On 2017-02-13 00:27, Cédric Krier wrote:
> On 2017-02-12 04:55, Khurram Shahzad wrote:
> > Dear All,
> >
> > The user can change his language from User -> Preferences -> Language. How
> > can we restrict user so that he/she can not change his language from user
> > menu.
> >
> > I have tried to add a record in Administration -> User Interface -> Models
> > -> Model Access -> Field Access for 'language' field in res_user with
> > 'read' access. But, even then the user can log in and change his language
> > using User -> Preference menu.
>
> There is not check access done when user set its preferences because it
> is his preferences (and also because only administrator has write access
> on res.user). So setting access on res.user does not change anything.

But indeed I just thought you could remove the language from the
User._context_fields, this will remove it from the preference dialog.
But side effect the UI will be in default language.
Otherwise you could override the User.set_preferences and remove any
language keys in values.

But I must say that I find very strange to want to prevent user to have
the UI in his preferred language.

Khurram Shahzad

unread,
Feb 13, 2017, 4:10:07 AM2/13/17
to try...@googlegroups.com
Dear Cedric,

Thanks for the response.
You are right! But, there should be some way to place some read only attributes in the users' context which are set by Administrator and can be viewed by user.

Khurram.

Cédric Krier

unread,
Feb 13, 2017, 4:30:07 AM2/13/17
to try...@googlegroups.com
On 2017-02-13 08:17, Khurram Shahzad wrote:
> You are right! But, there should be some way to place some read only
> attributes in the users' context which are set by Administrator and can be
> viewed by user.

I do not think it makes sense because the context is something that the
client set when calling the server so it is free to set what ever he
wants. Making it readonly on the UI will not increase any security
measurement.
But as I said previously we put in the context and preferences only
fields that are actually user preferences so there is no reason for the
administration to overrule that.

Khurram Shahzad

unread,
Feb 13, 2017, 11:40:10 AM2/13/17
to try...@googlegroups.com
Dear Cedric,
 
I do not think it makes sense because the context is something that the
client set when calling the server so it is free to set what ever he
wants. Making it readonly on the UI will not increase any security
measurement.
But as I said previously we put in the context and preferences only
fields that are actually user preferences so there is no reason for the
administration to overrule that.

Thanks a lot.
Reply all
Reply to author
Forward
0 new messages