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 Alexey Pelykh <notifications@github.com> - 19/11/2019 11:55:15

@alexey-pelykh requested changes on this pull request.


In hr_holidays_leave_auto_approve/models/hr_leave.py:

>                  values.get('holiday_status_id')
-            ).auto_approve
+            )
+            auto_approve = leave_type.auto_approve_policy != 'no'

Extract as def _should_auto_approve method


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):

Use _ to make this method non-RPC-callable


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':

Reuse _should_auto_approve ?

if record._should_auto_approve():
    record.sudo().action_approve()


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