GoodERP
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
1.1KB

  1. # Copyright 2016 上海开阖软件有限公司 (http://www.osbzr.com)
  2. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  3. from odoo import models, api
  4. from odoo import models, fields
  5. from datetime import datetime
  6. class MailMessage(models.Model):
  7. _inherit = 'mail.message'
  8. @api.model
  9. def staff_birthday_message(self):
  10. '''员工生日当天,whole company 会收到祝福信息'''
  11. newid = []
  12. staff_obj = self.env["staff"]
  13. for staff in staff_obj.search([]):
  14. if not staff.birthday:
  15. continue
  16. # 获取当前月日 和 员工生日
  17. now = datetime.now().strftime("%m-%d")
  18. staff_bir = staff.birthday.strftime("%m-%d")
  19. if now == staff_bir:
  20. values = {}
  21. # 创建一条祝福信息
  22. values['subject'] = "生日快乐!"
  23. values['model'] = "mail.channel"
  24. values['body'] = staff.name + ",祝你生日快乐!"
  25. values['res_id'] = 1
  26. newid.append(self.create(values))
  27. return newid
上海开阖软件有限公司 沪ICP备12045867号-1