콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
203 화면

Hello, 
In Odoo 12 CE, I am trying to do the following 
for HR department I set two approvals after the first approval from the direct manager the leave request not assigned to the leave manager and email not sent 
I need this process done automatically without manual reassigned.

I have tried many ways but not works with me  

아바타
취소
베스트 답변

Hi,

You can override the method that validates the first approval (action_approve) in the hr_holidays model and add logic to:

Reassign the request to the HR manager,

Send an email notification automatically.


Code:

from odoo import api, models


class HrLeave(models.Model):

    _inherit = 'hr.leave'


    @api.multi

    def action_approve(self):

        res = super(HrLeave, self).action_approve()


        for leave in self:

            # Check if double validation is needed

            if leave.holiday_status_id.validation_type == 'both':

                # Automatically reassign to HR Manager group

                hr_group = self.env.ref('hr_holidays.group_hr_holidays_manager')

                hr_manager_users = hr_group.users

                if hr_manager_users:

                    leave.write({'manager_id': hr_manager_users[0].id})


                    # Send email notification

                    template = self.env.ref('hr_holidays.mail_template_leave_approval_manager', raise_if_not_found=False)

                    if template:

                        self.env['mail.template'].browse(template.id).send_mail(leave.id, force_send=True)


        return res


Hope it helps

아바타
취소
관련 게시물 답글 화면 활동
3
9월 25
422
1
8월 25
555
1
7월 25
912
1
7월 25
1127
2
5월 25
1810