添加功能

This commit is contained in:
李鹏宇
2026-01-22 10:36:38 +08:00
parent 44e2b76531
commit 15069c8df3
8 changed files with 148 additions and 41 deletions
@@ -34,7 +34,7 @@
<field name="soong_record_ids" style="width:100%; margin-top: 10px;">
<tree create="1" edit="1" delete="1" editable="bottom" type="object">
<field name="workflow_record_id" domain="[('users_ids', 'in', uid)]"
options="{'no_open': True}"/>
options="{'no_open': True}" context="{'tree_view_ref': 'soong_workflow.soong_workflow_record_no_action_tree'}"/>
<field name="code" column_invisible="1"/>
<field name="workflow_id"/>
<field name="create_uid"/>
@@ -91,7 +91,7 @@
<field name="soong_record_ids" style="width:100%%; margin-top: 10px;">
<tree editable="bottom" delete="False">
<field name="workflow_record_id" domain="[('users_ids', 'in', uid)]"
options="{'no_open': True}"/>
options="{'no_open': True}" context="{'tree_view_ref': 'soong_workflow.soong_workflow_record_no_action_tree'}"/>
<field name="code" column_invisible="1"/>
<field name="workflow_id"/>
<field name="create_uid"/>
+48 -1
View File
@@ -128,7 +128,54 @@
</tree>
</field>
</record>
<record id="soong_workflow_record_no_action_tree" model="ir.ui.view">
<field name="name">soong.workflow.record.tree</field>
<field name="model">soong.workflow.record</field>
<field name="arch" type="xml">
<tree string="流程查询" type="object"
decoration-danger="approve_state == 'end'" delete="false"
create="false" default_order="write_date2 desc, id desc" expand="1" limit="10">
<header>
<button name="admin_end" type="object" string="管理员强制结束" class="oe_highlight"
groups="soong_workflow.group_soong_workflow_manager"/>
<button name="delete_record" type="object" string="删除" class="oe_highlight"
groups="soong_workflow.group_soong_workflow_manager"/>
</header>
<field name="code"/>
<field name="workflow_id" string="审批类型"/>
<field name="name"/>
<field name="approve_state" string="审批状态" widget="badge"
decoration-danger="approve_state == 'end'" decoration-success="approve_state == 'pending'"/>
<field name="create_uid"/>
<field name="employee_ids" widget="many2many_tags" string="当前经办人"/>
<field name="soong_state"/>
<field name="member_of_department" column_invisible="1"/>
<field name="node_id" string="当前节点" column_invisible="1"/>
<field name="documents_ids" widget="preview_many2many" column_invisible="1"/>
<field name="approvals_group_id" column_invisible="1"/>
<field name="department_id" column_invisible="1"/>
<field name="users_ids" string="用户" widget="many2many_tags" column_invisible="1"/>
<field name="write_date2" column_invisible="1"/>
<field name="company_id" column_invisible="1"/>
<field name="text" column_invisible="1"/>
<field name="reclaim_state" column_invisible="1"/>
<field name="is_manager" column_invisible="1"/>
<field name="meal" column_invisible="1"/>
<field name="workflow_happen_date" string="发生日期" column_invisible="1"/>
<button name="backend" type="object" string="后台" class="btn-primary"
groups="soong_workflow.group_soong_workflow_manager"/>
<button name="delete_record" type="object" string="删除" class="btn-primary"
confirm="你确定要删除吗?" groups="soong_workflow.group_soong_workflow_manager"/>
<button name="reminders_record" type="object" string="催办" class="btn-primary"
groups="soong_workflow.group_soong_workflow_manager"
invisible="approve_state in ['start', 'end']"/>
<button name="revoke_record" type="object" string="撤销" class="btn-primary"
groups="soong_workflow.group_soong_workflow_manager"/>
<button name="log" type="object" string="日志" class="btn-primary"
groups="soong_workflow.group_soong_workflow_manager"/>
</tree>
</field>
</record>
<record id="soong_workflow_record_form" model="ir.ui.view">
<field name="name">soong.workflow.record.form</field>
<field name="model">soong.workflow.record</field>
@@ -254,11 +254,10 @@ class OvertimeApprovals(models.Model):
def put_hr_employee(self):
for record in self:
for employee_id in record.employee_ids:
start_year = record.start_time.date().year
if record.company_id.name == "天河物管":
start_date = datetime(start_year, 3, 1).date()
valid_date = datetime(start_year + 1, 2, 1).date() + relativedelta(months=1) - relativedelta(days=1)
start_date = datetime(start_year, 9, 1).date()
valid_date = datetime(start_year + 1, 9, 1).date() + relativedelta(months=1) - relativedelta(days=1)
elif record.company_id.name == "天河粮储":
start_date = datetime(start_year, 7, 1).date()
valid_date = datetime(start_year + 1, 6, 30).date()
@@ -963,6 +963,7 @@ class VacationOverline(models.Model):
workflow_record_id = fields.Many2one('soong.workflow.record', string='流程')
update_type= fields.Selection([('add', '增加'), ('reduce', '减少')], string='更新类型')
workday = fields.Float(string='工作日')
last_balance = fields.Float(string='上年结余', compute='_compute_last_balance', store=True)
legal_day = fields.Float(string='法定节假日')
public_holidays = fields.Float(string='公休日')
meal_number = fields.Integer(string='误餐次数')
@@ -971,6 +972,7 @@ class VacationOverline(models.Model):
valid_date = fields.Date(string='有效期至')
adjust_date = fields.Date(string='调整至')
leave_date = fields.Date(string='请假日期')
total = fields.Float(string='总时长', compute='_compute_total')
overtime_methods = fields.Selection([('leave', '补休'), ('fee', '加班费结算')], string='加班补偿方式', default='leave')
text = fields.Text(string='备注')
is_confirm = fields.Boolean(string="是否确认")
@@ -983,12 +985,17 @@ class VacationOverline(models.Model):
duration = fields.Float(string="加班时长", compute="_compute_overtime", store=True)
carry_forward_quantity = fields.Float(string="结转时长")
validity = fields.Char(string="有效期")
carry_result = fields.Selection([('success', '成功'), ('failed', '失败')], string="结转结果")
is_active = fields.Boolean(string="归档")
carry_forward_state = fields.Selection([('pending', '待结转'),('completed', '已结转'), ('partial', '部分结转')
],string='结转状态',
default='pending',
)
remaining_quantity = fields.Float(string='剩余数', compute="_compute_remaining_quantity", store=True)
def confirm(self):
pass
def update_line(self):
over_ids = self.env["vacation.over.line"].browse(
self._context.get('active_ids', self._context.get('active_id')))
@@ -996,11 +1003,32 @@ class VacationOverline(models.Model):
rec._compute_remaining_quantity()
rec._compute_overtime()
rec._compute_employee_id()
rec._compute_last_balance()
@api.depends('duration', 'carry_forward_quantity')
@api.depends('public_holidays', 'workday', 'last_balance', 'valid_date')
def _compute_total(self):
current_date = date.today()
for record in self:
last_balance_contribution = record.last_balance
if record.valid_date and current_date > record.valid_date:
last_balance_contribution = 0.0
if record.is_initial_number:
record.total = record.duration
else:
record.total = record.public_holidays + record.workday + last_balance_contribution
@api.depends('total', 'carry_forward_quantity')
def _compute_remaining_quantity(self):
for rec in self:
rec.remaining_quantity = rec.duration - rec.carry_forward_quantity
rec.remaining_quantity = rec.total - rec.carry_forward_quantity
@api.depends('vacation_id')
def _compute_last_balance(self):
for rec in self:
if rec.vacation_id:
rec.last_balance = rec.vacation_id.last_holiday + rec.vacation_id.last_workday
else:
rec.last_balance = 0
@api.depends('vacation_id')
def _compute_employee_id(self):
@@ -13,11 +13,11 @@ export class CustomAttendanceVacationPutController extends ListController {
type: 'ir.actions.act_window',
res_model: 'hr.leave',
name: '请假情况',
view_mode: 'tree',
view_type: 'form',
views: [["yuthon_hr_attendance.view_hr_leave_statement_tree", 'tree']],
view_mode: 'tree,form',
view_type: 'tree',
views: [[false, 'tree']],
target: 'new', // 弹窗形式打开
context: {},
context: {'tree_view_ref': "yuthon_hr_attendance.view_hr_leave_statement_tree"},
});
}
@@ -30,7 +30,24 @@ export class CustomAttendanceVacationPutController extends ListController {
view_type: 'form',
views: [[false, 'tree']],
target: 'new',
context: {},
context: {'tree_view_ref': "yuthon_hr_attendance.view_yuthon_vacation_overtime_briefly_tree"},
domain: [
'|',
// 条件1:is_initial_number=true → 无视时间,直接显示
['is_initial_number', '=', true],
// 条件组2:is_initial_number=false + add + workflow_record_id≠空 + 非12月
'&', // 且:作用于「条件2」和「运算符&的结果」
['is_initial_number', '=', false],
'&', // 且:作用于「条件3」和「运算符&的结果」
['update_type', '=', 'add'],
'&', // 且:作用于「条件4」和「运算符!的结果」
['workflow_record_id', '!=', false],
// 时间过滤:只作用于第二类记录
'!', // 取反:不是2025年12月
'&',
['start_time', '>=', '2025-12-01 00:00:00'],
['start_time', '<', '2026-01-01 00:00:00']
],
});
}
@@ -43,7 +60,8 @@ export class CustomAttendanceVacationPutController extends ListController {
view_type: 'form',
views: [[false, 'tree']],
target: 'new',
context: {},
context: {'tree_view_ref': "yuthon_hr_attendance.view_yuthon_vacation_meal_tree"},
domain: [['meal_fee', '!=', 0]]
});
}
}
@@ -514,6 +514,37 @@
</form>
</field>
</record>
<record id="view_yuthon_vacation_overtime_briefly_tree" model="ir.ui.view">
<field name="name">vacation.over.line.overtime.briefly.tree</field>
<field name="model">vacation.over.line</field>
<field name="arch" type="xml">
<tree string="加班情况弹窗" editable="bottom">
<field name="employee_id"/>
<field name="last_balance" groups="yuthon_salary.group_lc_user,yuthon_salary.group_wg_user"/>
<field name="valid_date" groups="yuthon_salary.group_lc_user,yuthon_salary.group_wg_user"/>
<field name="workday"/>
<field name="public_holidays"/>
<field name="total"/>
<field name="carry_forward_quantity"/>
<field name="remaining_quantity"/>
</tree>
</field>
</record>
<record id="view_yuthon_vacation_overtime_active_tree" model="ir.ui.view">
<field name="name">vacation.over.line.overtime.tree</field>
<field name="model">vacation.over.line</field>
<field name="arch" type="xml">
<tree string="加班情况(归档)" editable="bottom">
<field name="overtime_name"/>
<field name="employee_id" invisible="1"/>
<field name="department_id"/>
<field name="carry_forward_quantity"/>
<field name="carry_forward_date"/>
<field name="is_active"/>
<field name="carry_result"/>
</tree>
</field>
</record>
<record id="view_yuthon_vacation_overtime_tree" model="ir.ui.view">
<field name="name">vacation.over.line.overtime.tree</field>
<field name="model">vacation.over.line</field>
@@ -561,6 +592,15 @@
<field name="context">{'search_default_now_month': 1, 'search_default_group_by_employee_id':1}</field>
<field name="view_id" ref="view_yuthon_vacation_overtime_tree"/>
<field name="search_view_id" ref="view_yuthon_vacation_overtime_search"/>
</record>
<record id="action_overtime_approval_active_report" model="ir.actions.act_window">
<field name="name">加班情况(归档)</field>
<field name="res_model">vacation.over.line</field>
<field name="view_mode">tree</field>
<field name="domain">['|', ('workflow_record_id','!=', False), ('is_initial_number', '=', True), ('update_type', '=', 'add'), ('is_active', '=', True)]</field>
<field name="context">{'search_default_group_by_employee_id':1}</field>
<field name="view_id" ref="view_yuthon_vacation_overtime_active_tree"/>
<field name="search_view_id" ref="view_yuthon_vacation_overtime_search"/>
</record>
<record id="update_vacation_over_line" model="ir.actions.server">
<field name="name">触发计算逻辑</field>
@@ -22,7 +22,7 @@ class PayCarryoverWizard(models.TransientModel):
is_2025_december = rec.vacation_date.year == 2026 and rec.vacation_date.month == 1
if rec.overtime_ids:
for overtime in rec.overtime_ids:
if overtime.text == '上月额度继承' and overtime.workday > 40:
if overtime.text == '上月额度继承' and overtime.total > 40:
reduce_workday = overtime.workday - 40
new_overtime = self.env['vacation.over.line'].create([{
'vacation_id': rec.id,
@@ -33,7 +33,7 @@ class PayCarryoverWizard(models.TransientModel):
'update_date': fields.Date.today(),
'is_void': False,
'overtime_methods': 'fee',
'text': f'{self.select_time}月份加班结算',
'text': f'{rec.vacation_date.month}月份加班结算',
}])
if is_2025_december and overtime.is_initial_number:
overtime.write({
@@ -15,29 +15,4 @@
<field name="implied_ids" eval="[(4, ref('module_yuthon_official_user'))]"/>
<field name="users" eval="[(4, ref('base.user_admin'))]"/>
</record>
<!-- <record model="ir.rule" id="yuthon_official_incoming_party_rule">-->
<!-- <field name="name">党总支收文多公司</field>-->
<!-- <field name="model_id" ref="model_yuthon_official_incoming_party"/>-->
<!-- <field name="domain_force">[('company_id', 'in', company_ids)]</field>-->
<!-- </record>-->
<!-- <record model="ir.rule" id="model_yuthon_official_incoming_labor_rule">-->
<!-- <field name="name">工会收文多公司</field>-->
<!-- <field name="model_id" ref="model_yuthon_official_incoming_labor"/>-->
<!-- <field name="domain_force">[('company_id', 'in', company_ids)]</field>-->
<!-- </record>-->
<!-- <record model="ir.rule" id="yuthon_official_incoming_normal_rule">-->
<!-- <field name="name">行政收文多公司</field>-->
<!-- <field name="model_id" ref="model_yuthon_official_incoming_normal"/>-->
<!-- <field name="domain_force">[('company_id', 'in', company_ids)]</field>-->
<!-- </record>-->
<!-- <record model="ir.rule" id="yuthon_official_labor_rule">-->
<!-- <field name="name">工会发文多公司</field>-->
<!-- <field name="model_id" ref="model_yuthon_official_labor"/>-->
<!-- <field name="domain_force">[('company_id', 'in', company_ids)]</field>-->
<!-- </record>-->
<!-- <record model="ir.rule" id="yuthon_official_party_rule">-->
<!-- <field name="name">党总支发文多公司</field>-->
<!-- <field name="model_id" ref="model_yuthon_official_party"/>-->
<!-- <field name="domain_force">[('company_id', 'in', company_ids)]</field>-->
<!-- </record>-->
</odoo>