GoodERP
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

35 lines
1.2KB

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