Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
219 Lượt xem

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  

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
3
thg 9 25
425
1
thg 8 25
557
1
thg 7 25
915
1
thg 7 25
1130
2
thg 5 25
1814