Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odpovědi
9402 Zobrazení

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"/>
</record>  

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. 

https://www.odoo.com/de_DE/forum/hilfe-1/question/open-form-with-a-user-related-record-88369 

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

Avatar
Zrušit
Nejlepší odpověď

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',
}
Avatar
Zrušit
Autor Nejlepší odpověď

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"',
                }
            </field>
       </record>  
Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
1
bře 15
3320
2
úno 23
1531
2
zář 15
5124
1
bře 15
8166
1
bře 15
3345