添加功能

This commit is contained in:
李鹏宇
2026-01-08 15:59:30 +08:00
parent 2d3eba7f20
commit 5c14e5bf86
6 changed files with 76 additions and 40 deletions
+10 -7
View File
@@ -32,10 +32,13 @@ class YuthonMealExpenses(models.Model):
return str(current_month)
def send_meal(self):
description = f'您有一条缴纳餐费,请及时查看,如有异议,请联系办公室进行复核。请于{self.select_year}年{self.select_time}月10日前将款项汇入指定账户:44001580909059000222 广州市天河投资集团有限公司(转账时请备注“姓名+XX月餐费”),并在完成付款后在集团oa的菜单:“我的”-“餐费”点击“已缴费'
url = f'https://oa.thtzjt.com/web#action=4579&model=yuthon.meal.expenses&view_type=list&menu_id=10922'
self.sudo().env["wecom.apps"].sync_send_message_textcard(category='oa', user_id=self.employee_id.wecom_userid,
title="缴纳餐费提醒", description=description,
url=url, btntxt="详细信息")
self.write({'meal_state': 'done'})
return {
'type': 'ir.actions.act_window',
'name': '餐费提醒',
'view_mode': 'form',
'res_model': 'party.meal.wizard',
'target': 'new',
'context': {'default_employee_ids': [(6, 0, [self.employee_id.id])],
'skip_party_month_onchange': True
},
}
+10 -7
View File
@@ -30,10 +30,13 @@ class YuthonSalaryParty(models.Model):
return str(current_month)
def send_party(self):
url = f'https://oa.thtzjt.com/web#action=4578&model=yuthon.salary.party&view_type=list&menu_id=10923'
self.sudo().env["wecom.apps"].sync_send_message_textcard(category='oa', user_id=self.employee_id.wecom_userid,
title="缴纳党费提醒",
description='你有一条缴纳党费,请及时查看并缴费',
url=url, btntxt="详细信息")
self.write({'party_state': 'done'})
return {
'type': 'ir.actions.act_window',
'name': '党费提醒',
'view_mode': 'form',
'res_model': 'party.send.wizard',
'target': 'new',
'context': {'default_employee_ids': [(6, 0, [self.employee_id.id])],
'skip_party_month_onchange': True
},
}
+33 -13
View File
@@ -31,23 +31,31 @@ class PartyMealWizard(models.TransientModel):
select_year = fields.Selection(selection=[(str(i), str(i)) for i in range(2024, 2040)], string='年份',
default=lambda self: str(datetime.now().year))
employee_ids = fields.Many2many('hr.employee', string='员工')
meal_month = fields.Selection([('1', '一月'), ('2', '二月'), ('3', '三月'), ('4', '四月'),
('5', '五月'), ('6', '六月'), ('7', '七月'), ('8', '八月'),
('9', '九月'), ('10', '十月'), ('11', '十一月'),
('12', '十二月')], string='用餐月份',
default=lambda self: self._get_default_month_and_year()[0])
meal_year = fields.Selection(selection=[(str(i), str(i)) for i in range(2024, 2040)], string='用餐年份', default=lambda self: self._get_default_month_and_year()[1] )
@api.onchange('meal_month', 'meal_year')
def _onchange_meal_month(self):
if self.env.context.get('skip_party_month_onchange'):
return
employee_list = []
meal_ids = self.env['yuthon.meal.expenses'].search([('select_time', '=', self.meal_month),
('select_year', '=', self.meal_year),
('meal_state', '=', 'to_do')
])
for meal_id in meal_ids:
employee_list.append(meal_id.employee_id.id)
self.employee_ids = [(6,0, employee_list)]
def confirm(self):
description = f'您有一条缴纳餐费,请及时查看,如有异议,请联系办公室进行复核。请于{self.select_year}年{self.select_time}月10日前将款项汇入指定账户:44001580909059000222 广州市天河投资集团有限公司(转账时请备注“姓名+XX月餐费”),并在完成付款后在集团oa的菜单:“我的”-“餐费”点击“已缴费'
url = f'https://oa.thtzjt.com/web#action=4579&model=yuthon.meal.expenses&view_type=list&menu_id=10922'
if self.select_time and self.select_year and not self.employee_ids:
meal_ids = self.env['yuthon.meal.expenses'].search([('select_time', '=', self.select_time),
('select_year', '=', self.select_year),
('meal_state', '=', 'to_do')
])
for meal in meal_ids:
self.sudo().env["wecom.apps"].sync_send_message_textcard(category='oa',
user_id=meal.employee_id.wecom_userid,
title="缴纳餐费提醒",
description=description,
url=url, btntxt="详细信息")
meal.write({'meal_state': 'done'})
if self.employee_ids:
for employee in self.employee_ids:
meal = self.env['yuthon.meal.expenses'].search([('employee_id', '=', employee.id),
@@ -63,3 +71,15 @@ class PartyMealWizard(models.TransientModel):
def _get_default_month(self):
current_month = datetime.now().month
return str(current_month)
def _get_default_month_and_year(self):
now = datetime.now()
current_year = now.year
current_month = now.month
if current_month == 1:
last_month = 12
last_year = current_year - 1
else:
last_month = current_month - 1
last_year = current_year
return str(last_month), str(last_year)
@@ -9,6 +9,8 @@
<group>
<field name="select_year"/>
<field name="select_time"/>
<field name="meal_year"/>
<field name="meal_month"/>
<field name="employee_ids" widget="many2many_tags" options="{'no_create': True}"/>
</group>
</group>
+19 -13
View File
@@ -30,22 +30,28 @@ class PartySendWizard(models.TransientModel):
select_year = fields.Selection(selection=[(str(i), str(i)) for i in range(2024, 2040)], string='年份',
default=lambda self: str(datetime.now().year))
employee_ids = fields.Many2many('hr.employee', string='员工')
party_month = fields.Selection([('1', '一月'), ('2', '二月'), ('3', '三月'), ('4', '四月'),
('5', '五月'), ('6', '六月'), ('7', '七月'), ('8', '八月'),
('9', '九月'), ('10', '十月'), ('11', '十一月'),
('12', '十二月')], string='缴费月',
default=lambda self: self._get_default_month())
party_year = fields.Selection(selection=[(str(i), str(i)) for i in range(2024, 2040)], string='缴费年', default=lambda self: str(datetime.now().year))
@api.onchange('party_month', 'party_year')
def _onchange_party_month(self):
if self.env.context.get('skip_party_month_onchange'):
return
employee_list = []
party_ids = self.env['yuthon.salary.party'].search([('select_time', '=', self.party_month),
('select_year', '=', self.party_year),
('party_state', '=', 'to_do')
])
for party_id in party_ids:
employee_list.append(party_id.employee_id.id)
self.employee_ids = [(6, 0, employee_list)]
def confirm(self):
url = f'https://oa.thtzjt.com/web#action=4578&model=yuthon.salary.party&view_type=list&menu_id=10923'
if self.select_time and self.select_year and not self.employee_ids:
party_ids = self.env['yuthon.salary.party'].search([('select_time', '=', self.select_time),
('select_year', '=', self.select_year),
('party_state', '=', 'to_do')
])
for party in party_ids:
self.sudo().env["wecom.apps"].sync_send_message_textcard(category='oa',
user_id=party.employee_id.wecom_userid,
title="缴纳党费提醒",
description='你有一条缴纳党费,请及时查看并缴费',
url=url, btntxt="详细信息")
party.write({'party_state': 'done'})
if self.employee_ids:
for employee in self.employee_ids:
party = self.env['yuthon.salary.party'].search([('employee_id', '=', employee.id),
@@ -9,6 +9,8 @@
<group>
<field name="select_year"/>
<field name="select_time"/>
<field name="party_year"/>
<field name="party_month"/>
<field name="employee_ids" widget="many2many_tags" options="{'no_create': True}"/>
</group>
</group>