@@ -50,6 +50,10 @@
|
||||
<button name="manage_confirmation" type="object" string="批量确认" class="oe_highlight"/>
|
||||
<button name="cleanup_march_2026" type="object" string="删除测试" class="oe_highlight"/>
|
||||
</header>
|
||||
<!-- 把详情/发送按钮放到最前面,方便操作 -->
|
||||
<button name="log" type="object" string="详情" class="oe_highlight"/>
|
||||
<button name="button_put" string="发送" invisible="vacation_state == 'confirmed'" type="object"
|
||||
class="oe_highlight" confirm="确认发送给该员工吗?"/>
|
||||
<field name="vacation_state" widget="badge" decoration-info="vacation_state == 'not_sent'"
|
||||
decoration-success="vacation_state == 'confirmed'"/>
|
||||
<field name="display_date"/>
|
||||
@@ -108,9 +112,6 @@
|
||||
<field name="year_sum" column_invisible="1"/>
|
||||
<field name="used_this_year1" column_invisible="1"/>
|
||||
<field name="working_overtime" column_invisible="1"/>
|
||||
<button name="log" type="object" string="详情" class="oe_highlight"/>
|
||||
<button name="button_put" string="发送" invisible="vacation_state == 'confirmed'" type="object"
|
||||
class="oe_highlight"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
@@ -862,7 +863,19 @@
|
||||
<field name="model_id" ref="yuthon_hr_attendance.model_yuthon_vacation_reports"/>
|
||||
<field name="binding_model_id" ref="yuthon_hr_attendance.model_yuthon_vacation_reports"/>
|
||||
<field name="state">code</field>
|
||||
<field name="code">action = model.all_put()</field>
|
||||
<field name="code">
|
||||
# 先弹出确认向导,由用户在向导里二次确认后再真正发送
|
||||
action = {
|
||||
'type': 'ir.actions.act_window',
|
||||
'name': '发送确认提醒',
|
||||
'res_model': 'vacation.put.wizard',
|
||||
'view_mode': 'form',
|
||||
'target': 'new',
|
||||
'context': {
|
||||
'default_vacation_ids': [(6, 0, env.context.get('active_ids', []))],
|
||||
},
|
||||
}
|
||||
</field>
|
||||
</record>
|
||||
<!-- <record id="all_confirm" model="ir.actions.server">-->
|
||||
<!-- <field name="name">批量确认</field>-->
|
||||
|
||||
@@ -13,23 +13,22 @@ class VacationPutWizard(models.TransientModel):
|
||||
_name = 'vacation.put.wizard'
|
||||
_description = '批量发送弹窗'
|
||||
|
||||
# 选中的考勤确认单
|
||||
vacation_ids = fields.Many2many('yuthon.vacation.reports', string='假期')
|
||||
# 选中的不重复员工数量,用于弹窗展示
|
||||
employee_count = fields.Integer(string='员工人数', compute='_compute_employee_count')
|
||||
|
||||
@api.depends('vacation_ids')
|
||||
def _compute_employee_count(self):
|
||||
""" 统计选中考勤单里不重复的员工数量 """
|
||||
for wizard in self:
|
||||
wizard.employee_count = len(wizard.vacation_ids.mapped('employee_id'))
|
||||
|
||||
def action_confirm(self):
|
||||
employee_reports_map = {}
|
||||
for report in self.vacation_ids:
|
||||
if not report.employee_id:
|
||||
continue
|
||||
emp = report.employee_id
|
||||
if emp not in employee_reports_map:
|
||||
employee_reports_map[emp] = report
|
||||
elif report.vacation_date > employee_reports_map[emp].vacation_date:
|
||||
employee_reports_map[emp] = report
|
||||
|
||||
# for employee, report in employee_reports_map.items():
|
||||
# we_id = employee.wecom_userid
|
||||
# message = f"你{self.select_year}年{self.select_time}月的考勤确认单已经生成,请到手机端确认",
|
||||
# if we_id:
|
||||
# self.sudo().env["wecom.apps"].sync_send_message(category='att', user_id=we_id, message=message,)
|
||||
# self.sudo().env["wecom.apps"].sync_send_message(category='att', user_id="18562027762", message=message,)
|
||||
# self.write({'confirm_status': 'un_confirm'})
|
||||
""" 用户确认后,把选中的记录通过 all_put 真正发送出去 """
|
||||
self.ensure_one()
|
||||
# 没有选中记录时给出提示,避免空发送
|
||||
if not self.vacation_ids:
|
||||
raise UserError(_('请先选择要发送的考勤确认单。'))
|
||||
# 以 active_ids 的形式把选中记录传回 all_put,保持原有发送逻辑不变
|
||||
return self.vacation_ids.with_context(active_ids=self.vacation_ids.ids).all_put()
|
||||
@@ -4,18 +4,25 @@
|
||||
<field name="name">vacation.put.wizard.form</field>
|
||||
<field name="model">vacation.put.wizard</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="批量确认弹窗">
|
||||
<form string="发送确认提醒">
|
||||
<div>
|
||||
只针对未确认的考勤确认单台账,确定要发送吗?
|
||||
确定要给 <field name="employee_count" readonly="1" class="oe_inline"/> 位员工发送考勤确认提醒吗?
|
||||
</div>
|
||||
<group>
|
||||
<field name="vacation_ids" invisible="1"/>
|
||||
<!-- 列出选中的考勤确认单,供用户二次核对 -->
|
||||
<field name="vacation_ids" readonly="1" nolabel="1">
|
||||
<tree>
|
||||
<field name="employee_id"/>
|
||||
<field name="display_date"/>
|
||||
<field name="vacation_state"/>
|
||||
</tree>
|
||||
</field>
|
||||
</group>
|
||||
<footer>
|
||||
<button string="确定" name="action_confirm" type="object" class="btn-primary"/>
|
||||
<button string="确定发送" name="action_confirm" type="object" class="btn-primary"/>
|
||||
<button string="取消" class="btn-secondary" special="cancel"/>
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
</odoo>
|
||||
|
||||
Reference in New Issue
Block a user