Odoo Help


Open form with current user record

Lucas Huber
on 10/8/15, 12:43 PM 1,108 views

I did try several ways to open my form view for the current user.

First with the model res.partner and second with the model res.users. Everything that I did try opens a form for a new record (partner/user).

<record id="act_membership_my_prefs" model="ir.actions.act_window">

<field name="name">My Preferences</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">res.users</field>
<field name="view_type">form</field>
<field name="active_id">1</field>
<field name="action_id" eval="ref('base.action_res_users_my')"/>
<field name="view_id" ref="membership_my_prefs_view"/>

As you see I did try with active_id and action_id, also I did try to use the domain function. 

The only relevant post I did find was this one. 


Note: I don't want to inheritate existing user or partner views! 

Axel Mendoza
On 10/8/15, 6:03 PM

You could vote it then at that link. :D

You should use a button of type object to return the action dict with the user id as the active_id in the context and also the res_id field of the action with the same value too. Like this:

    def open_user_form(self, cr, uid, ids, context=None):
return {
'type': 'ir.actions.act_window',
'name': 'Configure your Company',
'res_model': 'res.users',
'res_id': user_id,
'context': {'active_id': user_id},
'view_mode': 'form',
Lucas Huber
On 10/9/15, 5:50 AM

I did found somewhare a solution within the xml file, which more or less is doing the same. It works, but the view that I have created is not used. Instead a view from base that shows only the photo and some basic parameter will be used. Must be a typo in view_id.

        <record id="act_membership_my_prefs" model="ir.actions.server">

            <field name="name">My Preferences</field>
            <field name="model_id" ref="base.model_res_users"/>
            <field name="state">code</field>
            <field name="code">
                action = {
                    'type': 'ir.actions.act_window',
                    'name': 'My Preferences',
                    'view_mode': 'form',
                    'view_type': 'form',
                    'res_model': 'res.users',
                    'nodestroy': 'true',
                    'res_id': uid,
                    'views': [(False, 'form')],
                    'view_id': 'ref="membership_my_prefs_view"',

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

2 follower(s)


Asked: 10/8/15, 12:43 PM
Seen: 1108 times
Last updated: 10/9/15, 5:50 AM