This question has been flagged
1 Reply
11484 Views

Hello,

I added some customed fields by classic inheritance in the res.users model, as follows :

class TrelloUsers(models.Model):
    _inherit='res.users'

    trello_api_key=fields.Char('Trello API Key')
    trello_secret_token=fields.Char('Trello Secret Token')

Then, I modified the "Preferences" view to add those fields :

<record id="trello_view_preference_form" model="ir.ui.view">
    <field name="model">res.users</field>
    <field name="inherit_id" ref="base.view_users_form_simple_modif" />
    <field name="arch" type="xml">
      <xpath expr="//group[3]" position="after">
        <group string="Trello Settings">
          <field string="API Key" name="trello_api_key" readonly="0" />
          <field string="Secret Token" name="trello_secret_token" readonly="0" />
        </group>
      </xpath>
    </field>
</record>

It aims at allowing the concerned user to specify the data in those fields. But when I try to modify those data as an employee user, instead of admin user, I get an access error stating that only admins can modify these fields.

I can’t find information about how to give a user the necessary rights to modify some fields in the res.users model, but still make sure they can’t modify data of other users.

Thanks.

Cyrille (La LibreRie)

Avatar
Discard
Best Answer

Hi,

As the logged in user if you are able to read those values, it means that you have got the read access to the model res.users, as you are getting the access right issue, it means that currently logged in user group have to no access/permission to write to the model res.users.


For currently logged in user group(if anything particular), else for the employee group, allow the write access to the model res.users.

Normally user have rights to edit their own data, make sure that there is no issue in changing the other values in the preference form. To adjust the access right issue, activate the developer mode and navigate to Settings -> Technical -> Security -> Access Control List / Record Rules and adjust the existing rule or add new one for your case.

 

Thanks

Avatar
Discard
Author

The users can change the other values, but not the customed fields I added. I added a rule to give the employee group access to res.users. I does work now. Thanks for answer.