0

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?

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Cristin Meravi
  • 343
  • 2
  • 12

1 Answers1

0

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.

miw
  • 776
  • 4
  • 11
  • Or another way is create record rules and assign it to you group and assign that group to relevant user. Apart from hiding you can restrict to user. – Keval Mehta Aug 20 '18 at 07:21
  • OK, so I should include all non manager users under 2 groups, one that grans the permissions so that they can check in and out through the normal means, and one with only read access so that they can't create or edit in the tree view and form view? won't one set of permissions override the other? – Cristin Meravi Aug 20 '18 at 15:23
  • The non-managers go into your (new) group, and the managers into the (existing) group. Adding into 2 groups would result in them being able to create and edit again. – miw Aug 21 '18 at 05:56
  • The problem is the users need the create and edit permissions so that they can clock in and out. Thus negating your suggestion. – Cristin Meravi Aug 22 '18 at 13:04
  • Right, that's an issue with this approach... we'll need then 2 views, one with the create/edit button, the other without. And assign each to separate user groups so they get shown accordingly. The details still need to be worked out... – miw Aug 22 '18 at 21:39
  • Ok, that makes some sense and is something I can do. Is there a way to force the tree view in the version w/o create/edit to go to a secondary form view? – Cristin Meravi Aug 23 '18 at 13:50
  • The security groups are the way to make sure that the right views are selected. You can use this for the tree views and the same for a parallel pair of form views. There is no direct connection between the tree view and the form view. – miw Aug 25 '18 at 20:05