Reputation: 686
I would like to send a email to manager whenever a employee creates a leave request. This email should contain Approve and Reject Button . On clicking of these buttons in email ,the leaves should be approved or rejected.
Till now i am able to send a simple mail to manager without buttons. Here is my code :
def notifyLeads(object,self,vals):
print "sendnotifyLeads Called"
print vals['employee_id']
record = http.request.env['hr.employee'].search([('id', '=', vals['employee_id'])], limit=1)
holidayType = http.request.env['hr.holidays.status'].search([('id', '=', vals['holiday_status_id'])], limit=1)
print record.parent_id.work_email
mail_pool = self.env['mail.mail']
values={}
values.update({'subject': 'Leave request in Odoo'})
values.update({'email_to': record.parent_id.work_email })
values.update({'body_html': 'A Leave request from <h3>' +str(record.name) + '</h3>for <h3>' + str(vals['number_of_days_temp']) + ' days</h3> from <h3>' +str(vals['date_from']) + '</h3>Type: ' + str(holidayType.name)})
msg_id = mail_pool.create(values)
if msg_id:
result= msg_id.send()
print str(result)
I would like to add Approve and Reject button. Can someone tell me the workflow or example to implement this functionality?
Upvotes: 1
Views: 500
Reputation: 2764
For that you could just add two html links( tag) styled as buttons containing the url to approve and reject the leave. Then create two controller routes in a custom controller to handle the urls and make the actions on the leaves.
When the user receive the mail will see the two buttons and when click on them it will open the correspondent url. Also you could create a template to visualize the leave request state with the buttons to approve or reject it
Upvotes: 1