添加功能
This commit is contained in:
@@ -89,6 +89,8 @@
|
||||
'yuthon_hr_attendance/static/src/css/*.css',
|
||||
'yuthon_hr_attendance/static/src/js/planning_gantt_renderer.js',
|
||||
'yuthon_hr_attendance/static/src/xml/planning_gantt_renderer.xml',
|
||||
'yuthon_hr_attendance/static/src/js/button_vacation_put.js',
|
||||
'yuthon_hr_attendance/static/src/xml/button_vacation_put.xml',
|
||||
'yuthon_hr_attendance/static/src/planning_gantt/planning_gantt_controller.xml',
|
||||
],
|
||||
},
|
||||
|
||||
@@ -72,14 +72,14 @@ class YuthonVacationReports(models.Model):
|
||||
|
||||
vacation_state = fields.Selection(
|
||||
selection=[
|
||||
('unconfirmed', "未确认"),
|
||||
('not_sent', "未发送"),
|
||||
('confirmed', "已确认"),
|
||||
('pending', "待定"),
|
||||
('pending', "待确认"),
|
||||
],
|
||||
string="状态",
|
||||
readonly=True, copy=False, index=True,
|
||||
tracking=3,
|
||||
default='unconfirmed')
|
||||
default='not_sent')
|
||||
|
||||
@api.constrains('employee_id', 'vacation_date')
|
||||
def _check_duplicate_monthly_record(self):
|
||||
@@ -630,7 +630,7 @@ class YuthonVacationReports(models.Model):
|
||||
current_date = fields.Date.today()
|
||||
vacation_ids = self.env["yuthon.vacation.reports"].search([
|
||||
('vacation_date', '=', current_date.replace(day=1)),
|
||||
('vacation_state', '=', 'unconfirmed')
|
||||
('vacation_state', '!=', 'confirmed')
|
||||
])
|
||||
for rec in vacation_ids:
|
||||
month_start = current_date.replace(day=1)
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/** @odoo-module */
|
||||
import { ListController } from "@web/views/list/list_controller";
|
||||
import { registry } from '@web/core/registry';
|
||||
import { listView } from '@web/views/list/list_view';
|
||||
|
||||
export class CustomAttendanceVacationPutController extends ListController {
|
||||
setup() {
|
||||
super.setup();
|
||||
}
|
||||
|
||||
openVacationPutWizard() {
|
||||
this.actionService.doAction({
|
||||
type: 'ir.actions.act_window',
|
||||
res_model: 'vacation.put.wizard',
|
||||
name: '批量发送确认弹窗',
|
||||
view_mode: 'form',
|
||||
view_type: 'form',
|
||||
views: [[false, 'form']],
|
||||
target: 'new', // 以弹窗形式打开
|
||||
context: {},
|
||||
});
|
||||
}
|
||||
|
||||
openVacationConfirmWizard(){
|
||||
this.actionService.doAction({
|
||||
type: 'ir.actions.act_window',
|
||||
res_model: 'vacation.confirm.wizard',
|
||||
name: '批量确认弹窗',
|
||||
view_mode: 'form',
|
||||
view_type: 'form',
|
||||
views: [[false, 'form']],
|
||||
target: 'new', // 以弹窗形式打开
|
||||
context: {},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
registry.category("views").add("custom_vacation_put_button", {
|
||||
...listView,
|
||||
Controller: CustomAttendanceVacationPutController,
|
||||
buttonTemplate: "vacation_put_module.ListView.Buttons",
|
||||
});
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<templates>
|
||||
<t t-name="vacation_put_module.ListView.Buttons" t-inherit="web.ListView.Buttons">
|
||||
<xpath expr="//div[hasclass('o_list_buttons')]" position="after">
|
||||
<button type="button" class="btn btn-primary" style="margin-left: 10px;" t-on-click="openVacationConfirmWizard">
|
||||
批量确认
|
||||
</button>
|
||||
</xpath>
|
||||
<xpath expr="//div[hasclass('o_list_buttons')]" position="after">
|
||||
<button type="button" class="btn btn-primary" style="margin-left: 10px;" t-on-click="openVacationPutWizard">
|
||||
批量发送
|
||||
</button>
|
||||
</xpath>
|
||||
</t>
|
||||
</templates>
|
||||
@@ -4,11 +4,7 @@
|
||||
<field name="name">yuthon.vacation.reports.tree</field>
|
||||
<field name="model">yuthon.vacation.reports</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="假期额度记录" editable="bottom" edit="0" default_order="vacation_date desc">
|
||||
<header>
|
||||
<button name="all_put" type="object" string="批量发送" dclass="oe_highlight"/>
|
||||
<button name="all_confirm" type="object" string="批量确认" dclass="oe_highlight"/>
|
||||
</header>
|
||||
<tree string="假期额度记录" editable="bottom" edit="0" default_order="vacation_date desc" js_class="custom_vacation_put_button">
|
||||
<field name="vacation_state" widget="badge" decoration-info="vacation_state == 'unconfirmed'"
|
||||
decoration-success="vacation_state == 'confirmed'"/>
|
||||
<field name="employee_id" options="{'no_open': True}"/>
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import calendar
|
||||
|
||||
from dateutil.relativedelta import relativedelta
|
||||
|
||||
from odoo import models, api, fields, _
|
||||
from odoo.tools.float_utils import float_round
|
||||
from odoo.exceptions import ValidationError, UserError
|
||||
@@ -12,8 +15,15 @@ class VacationConfirmWizard(models.TransientModel):
|
||||
_name = 'vacation.confirm.wizard'
|
||||
_description = '批量确认弹窗'
|
||||
|
||||
company_id = fields.Many2one('res.company', string='公司', default=lambda self: self.env.user.company_id)
|
||||
|
||||
def action_confirm(self):
|
||||
reports = self.env["yuthon.vacation.reports"].search([('vacation_state', '=', 'unconfirmed')])
|
||||
today = date.today()
|
||||
vacation_date = (today - relativedelta(months=1)).replace(day=1)
|
||||
reports = self.env["yuthon.vacation.reports"].search([('vacation_state', '=', 'pending'),
|
||||
('vacation_date', '=', vacation_date),
|
||||
('company_id', '=', self.company_id.id)
|
||||
])
|
||||
for rec in reports:
|
||||
rec.vacation_state = 'confirmed'
|
||||
rec.vacation_state = 'pending'
|
||||
rec.automatic_confirmation()
|
||||
|
||||
@@ -8,6 +8,9 @@
|
||||
<div>
|
||||
确认要批量确认吗?
|
||||
</div>
|
||||
<group>
|
||||
<field name="company_id" invisible="1"/>
|
||||
</group>
|
||||
<footer>
|
||||
<button string="确定" name="action_confirm" type="object" class="btn-primary"/>
|
||||
<button string="取消" class="btn-secondary" special="cancel"/>
|
||||
|
||||
@@ -6,29 +6,21 @@ from odoo.exceptions import ValidationError, UserError
|
||||
from datetime import date
|
||||
from datetime import timedelta
|
||||
from datetime import datetime, time
|
||||
from dateutil.relativedelta import relativedelta
|
||||
|
||||
|
||||
class VacationPutWizard(models.TransientModel):
|
||||
_name = 'vacation.put.wizard'
|
||||
_description = '批量发送弹窗'
|
||||
|
||||
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))
|
||||
company_id = fields.Many2one('res.company', string='公司', default=lambda self: self.env.user.company_id.id)
|
||||
|
||||
def _get_default_month(self):
|
||||
current_month = datetime.now().month
|
||||
return str(current_month)
|
||||
|
||||
def action_confirm(self):
|
||||
year = int(self.select_year)
|
||||
month = int(self.select_time)
|
||||
vacation_date = datetime(year=year, month=month, day=1).date()
|
||||
reports = self.env["yuthon.vacation.reports"].search([('vacation_state', '=', 'unconfirmed'),
|
||||
today = date.today()
|
||||
vacation_date = (today - relativedelta(months=1)).replace(day=1)
|
||||
reports = self.env["yuthon.vacation.reports"].search([('vacation_state', '=', 'not_sent'),
|
||||
('company_id', '=', self.company_id.id),
|
||||
('vacation_date', '=', vacation_date)
|
||||
])
|
||||
if not reports:
|
||||
|
||||
@@ -9,8 +9,7 @@
|
||||
只针对未确认的考勤确认单台账,确定要发送吗?
|
||||
</div>
|
||||
<group>
|
||||
<field name="select_year"/>
|
||||
<field name="select_time"/>
|
||||
<field name="company_id" invisible="1"/>
|
||||
</group>
|
||||
<footer>
|
||||
<button string="确定" name="action_confirm" type="object" class="btn-primary"/>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<field name="contract_id"/>
|
||||
<field name="property_name"/>
|
||||
<field name="lessee_id"/>
|
||||
<button name="action_pay" string="核销" type="object" class="btn-primary"/>
|
||||
<button name="action_pay" string="核销" type="object" class="btn-primary" column_invisible="actual_date"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
Reference in New Issue
Block a user