Human Resources mailing list archives

hr@odoo-community.org

Avatar

Re: [OCA/hr] [12.0][IMP] hr_holidays_leave_auto_approve: Auto-approve for everyone (#663)

by Jaime Arroyo <notifications@github.com> - 19/11/2019 12:07:06

@jarroyomorales commented on this pull request.


In hr_holidays_leave_auto_approve/models/hr_leave.py:

> @@ -12,6 +12,13 @@ def _check_approval_update(self, state):
             return
         return super()._check_approval_update(state)
 
+    @api.multi
+    def apply_auto_approve_policy(self):
+        for record in self:
+            policy = record.holiday_status_id.auto_approve_policy
+            if (record.can_approve and policy == 'hr') or policy == 'all':

The whole function could be done in one line like this

self.filtered(lambda r: r._should_auto_approve()).sudo().action_approve()

but will we have possible future inheritance errors?


You are receiving this because you are on a team that was mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.