diff --git a/sh_backmate_theme_adv_enterprise/static/src/scss/form_view/form_view.scss b/sh_backmate_theme_adv_enterprise/static/src/scss/form_view/form_view.scss index c51520ef8..292e4469d 100644 --- a/sh_backmate_theme_adv_enterprise/static/src/scss/form_view/form_view.scss +++ b/sh_backmate_theme_adv_enterprise/static/src/scss/form_view/form_view.scss @@ -21,23 +21,24 @@ .o_action_manager .o_form_view_container .o_content .o_form_renderer .o_form_sheet_bg { max-width: 80%; margin: 0 auto; -} -.o_action_manager .o_form_view_container .o_content .o_form_renderer .o_form_sheet_bg .o_wrap_field .o_form_label { - width: 100px; - /* 固定宽度 */ - text-align: justify; - /* 启用两端对齐 */ - text-align-last: justify; - font-weight:700 !important; - opacity: 1 !important; - /* 最后一行也对齐 */ - /* 解决单行文本需触发对齐的问题 */ - &::after { - content: ''; - display: inline-block; - width: 100%; - /* 撑满宽度,触发对齐 */ + .o_wrap_field .o_form_label { + /* 固定宽度 */ + width: 100px; + /* 启用两端对齐 */ + text-align: justify; + /* 最后一行也对齐 */ + text-align-last: justify; + // 统一透明度 + opacity: 1 !important; + font-weight: 600; } } + +/* 添加红色星号在 label 后 */ +.o_wrap_field:has(.o_required_modifier) label.o_form_label::after { + content: "*"; + color: red; +} + //add end \ No newline at end of file diff --git a/sh_backmate_theme_adv_enterprise/static/src/views/form/form_controller.js b/sh_backmate_theme_adv_enterprise/static/src/views/form/form_controller.js index f10d83f57..0814ec248 100644 --- a/sh_backmate_theme_adv_enterprise/static/src/views/form/form_controller.js +++ b/sh_backmate_theme_adv_enterprise/static/src/views/form/form_controller.js @@ -4,7 +4,7 @@ import { session } from "@web/session"; import { FormController } from "@web/views/form/form_controller"; import { Mutex } from "@web/core/utils/concurrency"; import { useService } from "@web/core/utils/hooks"; -import { useState } from "@odoo/owl"; +import { useState, onMounted, useEffect } from "@odoo/owl"; const originalSetup = FormController.prototype.setup; const originalEdit = FormController.prototype.edit; const originalSaveButtonClicked = FormController.prototype.saveButtonClicked; @@ -25,22 +25,15 @@ patch(FormController.prototype, { this.buttonState = useState({ showEditButton: true, }) - const hasWorkEnd = this.props.fields.work_end; - if (hasWorkEnd && this.props.resId) { - const model = this.props.resModel; - const resId = this.props.resId; - this.orm.read(model, [resId], ["work_end"]).then((records) => { - const record = records[0]; - if (record && record.work_end === true) { - this.buttonState.showEditButton = false; - } - }) - } else { - this.buttonState.showEditButton = true; - } + onMounted(() => { + this.editButtonState(); + }) + // 监听resId变化 + useEffect(() => { + this.editButtonState(); + }, () => [this.model?.root?.resId]); // end edit originalSetup.call(this); - }, async edit() { @@ -71,6 +64,8 @@ patch(FormController.prototype, { await this.model.root.switchMode("readonly"); // } } + // 判断按钮状态 + this.editButtonState(); // } else { // this.model.actionService.doAction({ type: 'ir.actions.act_window_close' }); // } @@ -103,6 +98,37 @@ patch(FormController.prototype, { // } // return true; // } - -}) - + async editButtonState() { + try { + const fields = this.model.config.fields || this.props.fields; + const resModel = this.model.config.resModel || this.props.resModel; + const resId = this.model.config.resId || this.props.resId; + const currentUserId = this.env.services.user.userId; + if (resModel && resId) { + // 1. 判断是否存在 self_users_ids(经办人)字段 + if (fields.self_users_ids) { + const result = await this.orm.read(resModel, [resId], ["self_users_ids"]); + const selfUsers = result[0]?.self_users_ids || []; + if (!selfUsers.includes(currentUserId)) { + this.buttonState.showEditButton = false; + return; // 如果不是经办人,直接返回 + } + } + // 2. 判断 work_end 字段是否存在,且是否为 true + if (fields.work_end) { + const result = await this.orm.read(resModel, [resId], ["work_end"]); + const record = result[0]; + if (record && record.work_end === true) { + this.buttonState.showEditButton = false; + return; + } + } + // 3. 如果以上条件都不满足,则显示编辑按钮 + this.buttonState.showEditButton = true; + } + } catch (error) { + console.error("检查编辑按钮状态:", error); + this.buttonState.showEditButton = true; // 出错时默认显示编辑按钮 + } + } +}) \ No newline at end of file diff --git a/yuthon_holiday/models/inherit_hr_leave.py b/yuthon_holiday/models/inherit_hr_leave.py index d6c06caed..25b77f17a 100644 --- a/yuthon_holiday/models/inherit_hr_leave.py +++ b/yuthon_holiday/models/inherit_hr_leave.py @@ -148,6 +148,12 @@ class HrLeave(models.Model): ('22', '22:00'), ('22.5', '22:30'), ('23', '23:00'), ('23.5', '23:30')], string='结束时间') + def update_state(self): + leave_ids = self.env["hr.leave"].browse( + self._context.get('active_ids', self._context.get('active_id'))) + for leave in leave_ids: + leave.state = 'draft' + @api.model def create(self, vals): allocation = super(HrLeave, self).create(vals) @@ -201,7 +207,7 @@ class HrLeave(models.Model): self.env['vacation.over.line'].create({ 'vacation_id': reports_id.id, 'employee_id': employee.id, - 'update_type': 'add', + 'update_type': 'reduce', 'workday': allocation.number_of_days * 8, 'legal_day': 0, 'public_holidays': 0, diff --git a/yuthon_holiday/models/inherit_hr_leave_allocation.py b/yuthon_holiday/models/inherit_hr_leave_allocation.py index b73e31872..8c7e107ac 100644 --- a/yuthon_holiday/models/inherit_hr_leave_allocation.py +++ b/yuthon_holiday/models/inherit_hr_leave_allocation.py @@ -106,11 +106,11 @@ class HrLeaveAllocation(models.Model): @api.model def create(self, vals): allocation = super(HrLeaveAllocation, self).create(vals) + employee = allocation.employee_id + hours = allocation.number_of_hours_display if allocation.holiday_status_id.name == '年假' and allocation.state == 'validate': - employee = allocation.employee_id - days = allocation.number_of_hours_display employee.write({ - 'quota_issued': employee.quota_issued + days + 'quota_issued': employee.quota_issued + hours }) reports_id = self.env['yuthon.vacation.reports'].search([ ('employee_id', '=', employee.id) @@ -120,10 +120,24 @@ class HrLeaveAllocation(models.Model): 'vacation_id': reports_id.id, 'update_type': 'add', 'update_date': fields.Datetime.now(), - 'update_lines': days, + 'update_lines': hours, 'allocation_type': 'allocation', 'text': allocation.name }) + elif allocation.holiday_status_id.name == '补休': + reports_id = self.env['yuthon.vacation.reports'].search([ + ('employee_id', '=', employee.id) + ], limit=1) + self.env['vacation.over.line'].create({ + 'vacation_id': reports_id.id, + 'update_type': 'add', + 'update_date': fields.Datetime.now(), + 'workday': hours, + 'legal_day': 0, + 'public_holidays': 0, + 'meal_number': 0, + 'text': allocation.name + }) return allocation def unlink(self): @@ -132,20 +146,33 @@ class HrLeaveAllocation(models.Model): # 检查是否有需要同步的员工记录 if record.employee_id and record.holiday_status_id.name == '年假': employee = record.employee_id - days = record.number_of_hours_display + hours = record.number_of_hours_display lines_to_delete = self.env['vacation.leave.line'].search([ ('vacation_id.employee_id', '=', employee.id), ('update_type', '=', 'add'), - ('update_lines', '=', days), + ('update_lines', '=', hours), ('allocation_type', '=', 'allocation'), ('text', '=', record.name) ]) if lines_to_delete: lines_to_delete.is_void = True employee.write({ - 'quota_issued': employee.quota_issued - days + 'quota_issued': employee.quota_issued - hours }) - return super(HrLeaveAllocation, self).unlink() + elif record.employee_id and record.holiday_status_id.name == '补休': + employee = record.employee_id + hours = record.number_of_hours_display + lines_to_delete = self.env['vacation.over.line'].search([ + ('vacation_id.employee_id', '=', employee.id), + ('update_type', '=', 'add'), + ('workday', '=', hours), + ('text', '=', record.name) + ]) + if lines_to_delete: + lines_to_delete.is_void = True + + return super(HrLeaveAllocation, self).unlink() + def update_vacation(self): leave_ids = self.env["hr.leave.allocation"].browse( diff --git a/yuthon_holiday/views/hr_leave_batch.xml b/yuthon_holiday/views/hr_leave_batch.xml index 051b08425..47321f615 100644 --- a/yuthon_holiday/views/hr_leave_batch.xml +++ b/yuthon_holiday/views/hr_leave_batch.xml @@ -215,7 +215,13 @@ [('employee_id.user_id', '=', uid)] - + + 初始化状态 + + + code + action = model.update_state() +
- - - +
+
- + - - - diff --git a/yuthon_salary/models/inherit_hr_payslip.py b/yuthon_salary/models/inherit_hr_payslip.py index 061bcaafa..61613c440 100644 --- a/yuthon_salary/models/inherit_hr_payslip.py +++ b/yuthon_salary/models/inherit_hr_payslip.py @@ -448,7 +448,7 @@ class InheritHrPayslip(models.Model): } @api.depends('year_compute', 'year_jie', 'year_gong', 'jing_te', 'study_on', 'seniority_allowance', - 'position_salary', 'liquidation_year', + 'position_salary', 'liquidation_year', 'rank_salary', 'quality_allowance', 'high_subsidy', 'environmental_allowance', 'last_duty', 'seniority_salary', 'commuting_allowance', 'base_salary', 'performance_bonuses', 'comprehensive_subsidy', 'full_attendance_award', 'overtime_pay', 'based_pay', @@ -461,6 +461,7 @@ class InheritHrPayslip(models.Model): def _compute_total_before_tax(self): for record in self: record.total_before_tax = ( + record.rank_salary + record.condolence_fund + record.spring_festival + record.liquidation_year + @@ -518,7 +519,7 @@ class InheritHrPayslip(models.Model): record.b_year - record.union_dues - record.tax_payable - - record.maternity_allowance + + record.maternity_allowance - record.individual_income_tax + record.children_welfare_fee + record.add_income_tax +