Created
July 20, 2012 13:31
-
-
Save tejastank/3150725 to your computer and use it in GitHub Desktop.
OpenERP Leave Request shedular
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Need to import , import smtplib | |
def notify_leave_approval(self, cr, uid, ids=False, context=None): | |
print "leave notification...." | |
leave_ids = self.search(cr, uid, [('state','=','confirm')], context=context) | |
leaves = self.browse(cr, uid, leave_ids, context=context) | |
for leave in leaves: | |
email_from = leave.employee_id.work_email or "tejas.tank.mca@gmail.com" | |
email_to = leave.employee_id.parent_id.work_email or "tejas.tank.mca@gmail.com" | |
subject = "Auto Email Sender" | |
body = "Hello,\n\nPlease approve leave requests \n\nLeave Detail :: \n" + (leave.notes or "DUMMY") + "\n\nThanks,\n\n System Admin" | |
self.send_smtp_email(cr, uid, email_from, email_to, subject, body) | |
return True | |
def send_smtp_email(self, cr, uid, email_from, email_to, subject, body): | |
smtp_email_user = 'erthnet@gmail.com' | |
smtp_email_pwd = 'dearsonal' | |
smtpserver = smtplib.SMTP("smtp.gmail.com",587) | |
smtpserver.ehlo() | |
smtpserver.starttls() | |
smtpserver.ehlo | |
smtpserver.login(smtp_email_user, smtp_email_pwd) | |
header = 'To:' + email_to + '\n' + 'From: ' + email_from + '\n' + 'Subject:'+ subject +' \n' | |
msg = header + '\n ' + body + ' \n\n' | |
res = smtpserver.sendmail(email_from, email_to, msg) | |
smtpserver.close() | |
return res | |
# Need to create a scheduler and add this method. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment