Search code examples
xmlodooodoo-10time-and-attendance

odoo 10 hiding create/edit buttons for a particluar security group


Ok, so, I"m working in Odoo 10 and am trying to manage attendances using hr_attendances. I'm trying to hid the create and edit buttons in only the tree view and form view, however the Manual Attendances security group must have create and write permissions so that users can clock in and clock out using the normal means.

Here is what I've tried, but it doesn't seem like the is working.

<record id="timeclock_attendance_tree_manual" model="ir.ui.view">
  <field name="name">timeclock.attendance.tree.manual</field>
  <field name="model">hr.attendance</field>
  <field name="inherit_id" ref="hr_attendance.view_attendance_tree"/>
  <field name="groups_id" eval="[(4,ref('hr.group_hr_attendance'))]"/>
  <field name="arch" type="xml">
      <xpath expr="/tree" position="attributes">
          <attribute name="create">false</attribute>
          <attribute name="edit">false</attribute>
      </xpath>
  </field>
</record>

I've tried creating a security group that is separate and not inheriting to the other groups to see if that works. But this actually hides the buttons from everyone including the admin account. Is there anyone out there that can help me set this to only hide the buttons from the specified group?


Solution

  • Create 2 versions of the view, one with the create/edit to false, one with true. Assign the users to 2 different user groups, and set the group_ids of the views such that they are shown to each user group.

    Working with permissions directly would achieve showing the create/edit buttons only to those where desired. Unfortunately, as you pointed out in comments, they now cannot clock in and out anymore, since they miss the permissions.