Ken Kaneki
Ken Kaneki

Reputation: 135

How to use Security Group in Form Odoo?

I was created 4 groups access security in Odoo (a,b,c,d) this is Security.xml

<record model="ir.module.category" id="module_management">
          <field name="name">Digital</field>
          <field name="description">User access level for this module</field>
          <field name="sequence">4</field>
        </record>

        <record id="group_admin" model="res.groups">
          <field name="name">ADMIN</field>
          <field name="implied_ids" eval="[(4, ref('base.group_user'))]"/>
          <field name="category_id" ref="docdigital.module_management"/>
        </record>

        <record id="group_user_one" model="res.groups">
          <field name="name">User One</field>
          <field name="implied_ids" eval="[(4, ref('base.group_user'))]"/>
          <field name="category_id" ref="docdigital.module_management"/>
        </record>

        <record id="group_user_two" model="res.groups">
          <field name="name">User Two</field>
          <field name="implied_ids" eval="[(4, ref('base.group_user'))]"/>
          <field name="category_id" ref="docdigital.module_management"/>
        </record>

        <record id="group_team" model="res.groups">
          <field name="name">Team</field>
          <field name="implied_ids" eval="[(4, ref('base.group_user'))]"/>
          <field name="category_id" ref="docdigital.module_management"/>
        </record>

and i created my views xml. i wanna use groups access user group_user_one and group team. i'm try this first my code

<record id="projectimage_digital" model="ir.ui.view">
    <field name="name">Overview</field>
    <field name="model">project.digital</field>
    <field name="inherit_id" ref="docdigital.view_project_digital_form"/>
    <field name="arch" type="xml">
      <xpath expr="/form/sheet[1]/notebook[1]/page[1]" position="before">
        <attribute name="groups">group_user_one,group_team</attribute>
        <page string='Overview'>
        <group>
            <group>
            <field name="image_1" widget="image" class="oe_avatar"/>
            <field name="image_2" widget="image" class="oe_avatar"/>
            <field name="image_3" widget="image" class="oe_avatar"/>
            </group>
            <group>
            <field name="image_4" widget="image" class="oe_avatar"/>
            <field name="image_5" widget="image" class="oe_avatar"/>
            <field name="image_6" widget="image" class="oe_avatar"/>
            </group>                
        </group>
        </page>
      </xpath>
    </field>
  </record>

but not working, and i tried to add

<field name="groups" eval="[(4, ref('base.group_user_one'))]"/>

worked, but just one group. I wanna use two group.

Upvotes: 1

Views: 1894

Answers (1)

Charif DZ
Charif DZ

Reputation: 14721

I didn't understand what you need exactly but if you want to use more than one group

          <field name="groups" eval="[
                          (5,0,0), // put this first if you want to remove old groups
                         (4, ref('base.group_user_one')),
                          (4, ref('base.second_group')),
           ]"/>

When you use 4 command you are adding the group to old groups, (5,0,0) will remove all records

Upvotes: 1

Related Questions