From c6e09dcdbdc2567bafec229a532b191a0483c2fd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=A4=9C=E6=9C=AA=E5=A4=AE?= <2996985766@qq.com>
Date: Wed, 16 Jul 2025 21:37:43 +0800
Subject: [PATCH 1/6] =?UTF-8?q?=E4=BF=AE=E5=A4=8DresId=E9=97=AE=E9=A2=98?=
=?UTF-8?q?=E4=BB=A5=E5=8F=8A=E4=BC=98=E5=8C=96=E4=BA=A4=E4=BA=92?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../static/src/views/form/form_controller.js | 42 ++++++++++++-------
1 file changed, 27 insertions(+), 15 deletions(-)
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..f48b6b06c 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 } from "@odoo/owl";
const originalSetup = FormController.prototype.setup;
const originalEdit = FormController.prototype.edit;
const originalSaveButtonClicked = FormController.prototype.saveButtonClicked;
@@ -25,19 +25,9 @@ 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.etitButtonState();
+ })
// end edit
originalSetup.call(this);
@@ -71,6 +61,8 @@ patch(FormController.prototype, {
await this.model.root.switchMode("readonly");
// }
}
+ // 判断按钮状态
+ this.etitButtonState();
// } else {
// this.model.actionService.doAction({ type: 'ir.actions.act_window_close' });
// }
@@ -103,6 +95,26 @@ patch(FormController.prototype, {
// }
// return true;
// }
-
+ etitButtonState() {
+ const hasWorkEnd = this.model.config.fields.work_end ? this.model.config.fields.work_end : this.props.fields.work_end;
+ if (hasWorkEnd) {
+ const redModel = this.model.config.resModel ? this.model.config.resModel : this.props.resModel;
+ const resId = this.model.config.resId ? this.model.config.resId : this.props.resId;
+ if (redModel && resId) {
+ this.orm.read(redModel, [resId], ["work_end"]).then((records) => {
+ const record = records[0];
+ if (record && record.work_end === true) {
+ this.buttonState.showEditButton = false;
+ } else {
+ this.buttonState.showEditButton = true;
+ }
+ })
+ } else {
+ this.buttonState.showEditButton = true;
+ }
+ } else {
+ this.buttonState.showEditButton = true;
+ }
+ }
})
From ad06e1e2457de2c6e76b399789e9775e2e347a4e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=A4=9C=E6=9C=AA=E5=A4=AE?= <2996985766@qq.com>
Date: Thu, 17 Jul 2025 12:08:18 +0800
Subject: [PATCH 2/6] =?UTF-8?q?=E4=BC=98=E5=8C=96label=E6=96=87=E6=9C=AC?=
=?UTF-8?q?=E7=BB=9F=E4=B8=80=EF=BC=8C=E7=BC=96=E8=BE=91=E6=8C=89=E9=92=AE?=
=?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=BB=8F=E5=8A=9E=E4=BA=BA=E9=80=BB=E8=BE=91?=
=?UTF-8?q?=E5=88=A4=E6=96=AD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../static/src/scss/form_view/form_view.scss | 37 ++++++++-------
.../static/src/views/form/form_controller.js | 45 ++++++++++---------
2 files changed, 46 insertions(+), 36 deletions(-)
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..174ab857e 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,28 @@
.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_form_sheet {
+ box-shadow: 0px 2px 11px 0px black;
+ }
+
+ .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 f48b6b06c..2d2c83459 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
@@ -95,26 +95,31 @@ patch(FormController.prototype, {
// }
// return true;
// }
- etitButtonState() {
- const hasWorkEnd = this.model.config.fields.work_end ? this.model.config.fields.work_end : this.props.fields.work_end;
- if (hasWorkEnd) {
- const redModel = this.model.config.resModel ? this.model.config.resModel : this.props.resModel;
- const resId = this.model.config.resId ? this.model.config.resId : this.props.resId;
- if (redModel && resId) {
- this.orm.read(redModel, [resId], ["work_end"]).then((records) => {
- const record = records[0];
- if (record && record.work_end === true) {
- this.buttonState.showEditButton = false;
- } else {
- this.buttonState.showEditButton = true;
- }
- })
- } else {
- this.buttonState.showEditButton = true;
+ async etitButtonState() {
+ 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;
+ // 默认显示按钮
+ this.buttonState.showEditButton = true;
+ 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;
+ }
}
- } else {
- this.buttonState.showEditButton = true;
}
}
-})
-
+})
\ No newline at end of file
From e13e49f12e2b84d8469e13b13ab69c43d1056eb2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=A4=9C=E6=9C=AA=E5=A4=AE?= <2996985766@qq.com>
Date: Thu, 17 Jul 2025 12:11:08 +0800
Subject: [PATCH 3/6] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E6=9C=AC=E5=9C=B0?=
=?UTF-8?q?=E6=B5=8B=E8=AF=95=E4=BB=A3=E7=A0=81=EF=BC=8Cform=E9=98=B4?=
=?UTF-8?q?=E5=BD=B1=E6=95=88=E6=9E=9C?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../static/src/scss/form_view/form_view.scss | 4 ----
1 file changed, 4 deletions(-)
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 174ab857e..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
@@ -22,10 +22,6 @@
max-width: 80%;
margin: 0 auto;
- .o_form_sheet {
- box-shadow: 0px 2px 11px 0px black;
- }
-
.o_wrap_field .o_form_label {
/* 固定宽度 */
width: 100px;
From 46db1f656e982769df32be5c80476858e5dad2f9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=A4=9C=E6=9C=AA=E5=A4=AE?= <2996985766@qq.com>
Date: Thu, 17 Jul 2025 14:48:08 +0800
Subject: [PATCH 4/6] =?UTF-8?q?=E5=A2=9E=E5=8A=A0form=E9=A1=B5=E9=9D=A2?=
=?UTF-8?q?=E5=88=87=E6=8D=A2=E5=A4=84=E7=90=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
form页面点击上一页下一页时,监听formid,发生变化时,重新获取按钮状态
---
.../static/src/views/form/form_controller.js | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
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 2d2c83459..cb5f7e5c7 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, onMounted } 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;
@@ -28,9 +28,12 @@ patch(FormController.prototype, {
onMounted(() => {
this.etitButtonState();
})
+ // 监听resId变化
+ useEffect(() => {
+ this.etitButtonState();
+ }, () => [this.model?.root?.resId]);
// end edit
originalSetup.call(this);
-
},
async edit() {
@@ -100,8 +103,6 @@ patch(FormController.prototype, {
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;
- // 默认显示按钮
- this.buttonState.showEditButton = true;
if (resModel && resId) {
// 1. 判断是否存在 self_users_ids(经办人)字段
if (fields.self_users_ids) {
@@ -118,8 +119,11 @@ patch(FormController.prototype, {
const record = result[0];
if (record && record.work_end === true) {
this.buttonState.showEditButton = false;
+ return;
}
}
+ // 3. 如果以上条件都不满足,则显示编辑按钮
+ this.buttonState.showEditButton = true;
}
}
})
\ No newline at end of file
From 04ec5dde0401a141c2a4e4a05f57751e47309b7e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=A4=9C=E6=9C=AA=E5=A4=AE?= <2996985766@qq.com>
Date: Thu, 17 Jul 2025 14:54:26 +0800
Subject: [PATCH 5/6] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=BC=82=E5=B8=B8?=
=?UTF-8?q?=E5=A4=84=E7=90=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../static/src/views/form/form_controller.js | 57 ++++++++++---------
1 file changed, 31 insertions(+), 26 deletions(-)
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 cb5f7e5c7..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
@@ -26,11 +26,11 @@ patch(FormController.prototype, {
showEditButton: true,
})
onMounted(() => {
- this.etitButtonState();
+ this.editButtonState();
})
// 监听resId变化
useEffect(() => {
- this.etitButtonState();
+ this.editButtonState();
}, () => [this.model?.root?.resId]);
// end edit
originalSetup.call(this);
@@ -65,7 +65,7 @@ patch(FormController.prototype, {
// }
}
// 判断按钮状态
- this.etitButtonState();
+ this.editButtonState();
// } else {
// this.model.actionService.doAction({ type: 'ir.actions.act_window_close' });
// }
@@ -98,32 +98,37 @@ patch(FormController.prototype, {
// }
// return true;
// }
- async etitButtonState() {
- 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; // 如果不是经办人,直接返回
+ 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;
+ // 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;
}
- // 3. 如果以上条件都不满足,则显示编辑按钮
- this.buttonState.showEditButton = true;
+ } catch (error) {
+ console.error("检查编辑按钮状态:", error);
+ this.buttonState.showEditButton = true; // 出错时默认显示编辑按钮
}
}
})
\ No newline at end of file
From a635f47e231bfa805b0c79d2cb838e18745a916c Mon Sep 17 00:00:00 2001
From: zhou <123@>
Date: Thu, 17 Jul 2025 15:40:03 +0800
Subject: [PATCH 6/6] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
yuthon_holiday/models/inherit_hr_leave.py | 8 +-
.../models/inherit_hr_leave_allocation.py | 43 +++++--
yuthon_holiday/views/hr_leave_batch.xml | 8 +-
.../models/property_split_approval.py | 111 +++++++++++++++---
.../views/property_split_approval_views.xml | 17 +--
yuthon_salary/models/inherit_hr_payslip.py | 5 +-
6 files changed, 159 insertions(+), 33 deletions(-)
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()
+