GoodERP
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

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