This question has been flagged
1 Reply
3585 Views

Hi.

I want to add a new attribute (like the email-address for example) to res.users making it possible for every user to update this attribute in his user settings dialog (upper right corner).

To make it short, everythings works as expected with the exception that only the administrator is able to edit this attribute in the user settings screen. For every one else it is read only.

Basically I added the new attribute to res.users

class res_users(osv.osv):
    _inherit = 'res.users
    _columns = {
        'color': fields.char('Color (hex)', size=6),
    }

And extended the view like this

<record id="view_user_my_settings_form" model="ir.ui.view">
    <field name="name">res.users.preferences.form.inherit</field>
    <field name="model">res.users</field>
    <field name="inherit_id" ref="base.view_users_form_simple_modif" />
    <field name="arch" type="xml">
        <data>
            <xpath expr="//group[@name='preferences']" position="inside">
                <field name="color"/>
            </xpath>
        </data>
    </field>
</record>

Any idea what I missed?

Regards

Mark

Update:

Thanks to Ben Bernard I discovered my mistake. After forcing the field to writeable mode I got an error that the user is not allowed to change res.users. So my solution is to move the attribute from res.users to res.partner.

Avatar
Discard
Best Answer

<field name="color" readonly="0"/>

Avatar
Discard