42 lines
2.1 KiB
Python
42 lines
2.1 KiB
Python
from odoo import api, fields, models
|
|
from datetime import datetime
|
|
|
|
|
|
class YuthonSalaryParty(models.Model):
|
|
_name = 'yuthon.salary.party'
|
|
_description = '党建'
|
|
|
|
employee_id = fields.Many2one('hr.employee', string='姓名')
|
|
card = fields.Char(string='身份找')
|
|
fee = fields.Float(string='党费')
|
|
payment = fields.Float(string='补缴党费')
|
|
total_payment = fields.Float(string='合计缴费')
|
|
company_id = fields.Many2one(related='employee_id.company_id', string="公司")
|
|
select_time = fields.Selection([('1', '一月'), ('2', '二月'), ('3', '三月'), ('4', '四月'),
|
|
('5', '五月'), ('6', '六月'), ('7', '七月'), ('8', '八月'),
|
|
('9', '九月'), ('10', '十月'), ('11', '十一月'),
|
|
('12', '十二月')], string='月份',
|
|
default=lambda self: self._get_default_month())
|
|
select_year = fields.Selection(selection=[(str(i), str(i)) for i in range(2024, 2040)], string='年份',
|
|
default=lambda self: str(datetime.now().year))
|
|
party_state = fields.Selection([('to_do', '待发送'), ('done', '已发送')], string='状态', default='to_do')
|
|
|
|
|
|
def _get_default_month(self):
|
|
current_month = datetime.now().month
|
|
return str(current_month)
|
|
|
|
def send_party(self):
|
|
pay_year_month = self.select_year + '年' + self.select_time + '月'
|
|
message = f"""【{pay_year_month}缴纳党费通知】:
|
|
请于{fields.Date.today()}(今天)15:00前将党费按时汇入账户:44001580909059000222 广州市天河投资集团有限公司,
|
|
并在群里告知汇款完毕。
|
|
您当月的缴费金额为{self.total_payment},其中党费{self.fee},补缴党费{self.payment}。"""
|
|
self.sudo().env["wecom.apps"].sync_send_message(
|
|
category='att',
|
|
user_id=self.employee_id.wecom_userid,
|
|
message=message,
|
|
)
|
|
self.write({'party_state': 'done'})
|
|
|