Aide

0

Odoo[13] Wrong Form View when Browser Tab is refreshed (PF5) groups_id disregarded

Avatar
Mayte Montaño

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