Odoo Help

Welcome!

This community 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.

0

Open form with current user record

By
Lucas Huber
on 10/8/15, 12:43 PM 606 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"/>
</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! 

2

Axel Mendoza

--Axel Mendoza--
10308
| 7 7 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full time employee trying to understand what to do an how

Reach me at aekroft@gmail.com

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',
}
0
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"',
                }
            </field>
       </record>  

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

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