Skip to Content
Menu
This question has been flagged

I am working on Odoo v13.0; and have 2 form views with the same priority and different user.groups:

  • view_id=1 has groups_ids='my_module.user_group_1'

  • view_id=2 has groups_ids='my_module.user_group_2'

When user with group user_group_2 (that does not have user_group_1) signs in then the correct view is displayed (view_id=2) as well as when displaying the form thru the usual menu actions; however if browser tab is refreshed (PF5) then view_id=1 is displayed.

I tried changing the view's priority but then the lowest priority is always displayed when PF5 regardless of user.group.


I found a work around by overriding model's fields_view_get but I wonder if I am missing something here.

 <!-- Form View for user_group_1 -->
<record model="ir.ui.view" id="user_group_1_form_view">
<field name="name">my.model.form.view.1</field>
<field name="model">sccc.provider</field>
       <field name="groups_id" eval="[(4, ref('user_group_1'))]"/>
<field name="arch" type="xml">
<form string="My Group 1 Form">
            <sheet>
                <group>
                    <field name="nick_name" required="1"/>
                    <field name="dob" required="1"/>
</group>
</sheet>
</form>
</field>
</record>
    <!-- Form View for user_group_2 -->
<record model="ir.ui.view" id="user_group_2_form_view">
<field name="name">my.model.form.view.2</field>
<field name="model">sccc.provider</field>
       <field name="groups_id" eval="[(4, ref('user_group_2'))]"/>
<field name="arch" type="xml">
<form string="My Group 2 Form">
            <sheet>
                <group>
                    <field name="first_name" required="1"/>
                    <field name="last_name" required="1"/>
</group>
</sheet>
</form>
</field>
  </record>

Avatar
Discard
Related Posts Replies Views Activity
2
May 20
2822
2
Dec 22
1715
1
Jun 22
4651
1
Sep 21
2454
2
May 24
526