I'm working on a module extendig Odoo's Attendance. My goal is to make only records meeting a condition editable while others stay readonly.
I've created an additional field user_editable to imitate the future condition, but alas this does not work. All shown entries are set to readonly.
What am I missing?
These are my record rules adapted from existing ones.
<odoo>
<record id="mymodule_attendance_rule_create" model="ir.rule">
<field name="name">user: modify own attendance only</field>
<field name="model_id" ref="hr_attendance.model_hr_attendance"/>
<field name="domain_force">[('employee_id.user_id','=',user.id)]</field>
<field name="perm_read" eval="0"/>
<field name="perm_write" eval="0"/>
<field name="perm_create" eval="1"/>
<field name="perm_unlink" eval="0"/>
<field name="groups" eval="[(4,ref('base.group_user'))]"/>
</record>
<record id="mymodule_attendance_rule_change" model="ir.rule">
<field name="name">user: modify only last three workdays' attendance</field>
<field name="model_id" ref="hr_attendance.model_hr_attendance"/>
<field name="domain_force">[
('user_editable','=',True),
('employee_id.user_id','=',user.id)
]</field>
<field name="perm_read" eval="0"/>
<field name="perm_write" eval="1"/>
<field name="perm_create" eval="0"/>
<field name="perm_unlink" eval="1"/>
<field name="groups" eval="[(4,ref('base.group_user'))]"/>
</record>
</odoo>
As far as I understand the second one should be evaluated when the user tries to edit an entry, which, however, is uneditable in frontend upon installing the module.
Here's a defitinion of my extra field:
class HrAttendance(models.Model):
_inherit = "hr.attendance"
user_editable = fields.Boolean(string='User editable',
store=True,
compute='_compute_user_editable')
_compute_user_editable currently just sets "True".
Thanks!