تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
9404 أدوات العرض

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! 

الصورة الرمزية
إهمال
أفضل إجابة

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',
}
الصورة الرمزية
إهمال
الكاتب أفضل إجابة

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>  
الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
1
مارس 15
3323
2
فبراير 23
1535
2
سبتمبر 15
5133
1
مارس 15
8169
1
مارس 15
3345