birthday reminder
This commit is contained in:
parent
d69ca61bc9
commit
e734c1d13c
|
|
@ -1,6 +1,8 @@
|
|||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, fields, models
|
||||
from datetime import timedelta, datetime, date
|
||||
|
||||
|
||||
|
||||
class HrEmployee(models.Model):
|
||||
|
|
@ -66,3 +68,23 @@ class HrEmployee(models.Model):
|
|||
''', (tuple(self.env.companies.ids),))
|
||||
|
||||
return self.env.cr.dictfetchall()
|
||||
|
||||
@api.model
|
||||
def send_birthday_reminders(self):
|
||||
today = datetime.today().strftime('%m-%d')
|
||||
employees = self.search([('birthday', '!=', False)])
|
||||
|
||||
birthday_emps = employees.filtered(
|
||||
lambda emp: emp.birthday.strftime('%m-%d') == today
|
||||
)
|
||||
|
||||
if birthday_emps:
|
||||
channel = self.env['discuss.channel'].search([('name', 'ilike', 'General')], limit=1)
|
||||
if channel:
|
||||
for emp in birthday_emps:
|
||||
message = f"🎉 Happy Birthday {emp.name}! 🎂 Wishing you a fantastic day! 🥳"
|
||||
channel.message_post(
|
||||
body=message,
|
||||
message_type='comment',
|
||||
subtype_xmlid='mail.mt_comment'
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in New Issue