@@ -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
|
||||
@@ -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; // 出错时默认显示编辑按钮
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -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,
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -215,7 +215,13 @@
|
||||
<field name="search_view_id" ref="hr_leave_batch_search_view"/>
|
||||
<field name="domain">[('employee_id.user_id', '=', uid)]</field>
|
||||
</record>
|
||||
|
||||
<record id="all_update_state" model="ir.actions.server">
|
||||
<field name="name">初始化状态</field>
|
||||
<field name="model_id" ref="hr_holidays.model_hr_leave"/>
|
||||
<field name="binding_model_id" ref="hr_holidays.model_hr_leave"/>
|
||||
<field name="state">code</field>
|
||||
<field name="code">action = model.update_state()</field>
|
||||
</record>
|
||||
<menuitem
|
||||
id="hr_holidays.hr_leave_menu_my"
|
||||
parent="hr_holidays.menu_hr_holidays_my_leaves"
|
||||
|
||||
@@ -52,21 +52,107 @@ class PropertySplitApproval(models.Model):
|
||||
def put_split_message(self):
|
||||
property_list = []
|
||||
for property_split in self.property_split_approval_line_ids:
|
||||
main_property = self.property_id
|
||||
property_id = self.env['yuthon.property'].create({
|
||||
'name': property_split.split_property,
|
||||
'building_area': property_split.split_building_area,
|
||||
'rent_area': property_split.split_rent_area,
|
||||
'asset_type_id': property_split.split_asset_type_id.id,
|
||||
'property_merge_approval_id':self.property_id.id,
|
||||
'effective_date':self.effective_date,
|
||||
'asset_type_id': main_property.asset_type_id.id,
|
||||
'property_merge_approval_id': main_property.id,
|
||||
'is_electricity_meter': main_property.is_electricity_meter,
|
||||
'is_meter': main_property.is_meter,
|
||||
'is_message_fee': main_property.is_message_fee,
|
||||
'units': main_property.units,
|
||||
'district': main_property.district,
|
||||
'property_building_id': main_property.property_building_id.id,
|
||||
'property_orientation': main_property.property_orientation,
|
||||
'street': main_property.street,
|
||||
'property_source': main_property.property_source,
|
||||
'live_room': main_property.live_room.id,
|
||||
'house_type_id': main_property.house_type_id.id,
|
||||
'feature_ids': main_property.feature_ids.ids,
|
||||
'rental_conditions': main_property.rental_conditions,
|
||||
'property_floor_id': main_property.property_floor_id.id,
|
||||
'effective_date': self.effective_date,
|
||||
'is_done_merge': True
|
||||
})
|
||||
property_list.append([0, 0, {'property_id':property_id.id,
|
||||
'start_time': self.effective_date,
|
||||
}])
|
||||
self.property_id.write({'is_done_split': True})
|
||||
self.property_id.disassembly_information_ids = property_list
|
||||
|
||||
if main_property.water_meter_ids:
|
||||
water_vals = [
|
||||
(0, 0, {
|
||||
'property_meter_water_id': water.property_meter_water_id.id,
|
||||
'yuthon_property_id': property_id.id
|
||||
}) for water in main_property.water_meter_ids
|
||||
]
|
||||
property_id.water_meter_ids = water_vals
|
||||
|
||||
if main_property.energy_meter_ids:
|
||||
energy_vals = [
|
||||
(0, 0, {
|
||||
'property_meter_archives_id': energy.property_meter_archives_id.id,
|
||||
'yuthon_property_id': property_id.id
|
||||
}) for energy in main_property.energy_meter_ids
|
||||
]
|
||||
property_id.energy_meter_ids = energy_vals
|
||||
|
||||
if main_property.title_information_ids:
|
||||
title_vals = [
|
||||
(0, 0, {
|
||||
'property_message_id': line.property_message_id.id,
|
||||
'start_time': line.start_time,
|
||||
'end_date': line.end_date,
|
||||
'yuthon_property_id': property_id.id
|
||||
}) for line in main_property.title_information_ids
|
||||
]
|
||||
property_id.title_information_ids = title_vals
|
||||
|
||||
if main_property.manage_information_ids:
|
||||
manage_vals = [
|
||||
(0, 0, {
|
||||
# 核心:设置拆分后的管理面积和可租面积
|
||||
'management_area': property_split.split_building_area,
|
||||
'rent_area': property_split.split_rent_area,
|
||||
'purpose_id': line.purpose_id.id,
|
||||
'precinct_id': line.precinct_id.id,
|
||||
'tenure_type': line.tenure_type,
|
||||
'admin_id': line.admin_id.id,
|
||||
'company_id': line.company_id.id,
|
||||
'start_time': line.start_time,
|
||||
'end_date': line.end_date,
|
||||
'yuthon_property_id': property_id.id
|
||||
}) for line in main_property.manage_information_ids
|
||||
]
|
||||
property_id.manage_information_ids = manage_vals
|
||||
|
||||
if main_property.assessment_ids:
|
||||
assessment_vals = [
|
||||
(0, 0, {
|
||||
'name': line.name, # 复制评估名称
|
||||
'yuthon_property_id': property_id.id
|
||||
}) for line in main_property.assessment_ids
|
||||
]
|
||||
property_id.assessment_ids = assessment_vals
|
||||
|
||||
if main_property.repair_ids:
|
||||
repair_vals = [
|
||||
(0, 0, {
|
||||
'name': line.name,
|
||||
'yuthon_property_id': property_id.id
|
||||
}) for line in main_property.repair_ids
|
||||
]
|
||||
property_id.repair_ids = repair_vals
|
||||
|
||||
if main_property.produce_ids:
|
||||
produce_vals = [
|
||||
(0, 0, {
|
||||
'produce_id': line.produce_id.id,
|
||||
'yuthon_property_id': property_id.id
|
||||
}) for line in main_property.produce_ids
|
||||
]
|
||||
property_id.produce_ids = produce_vals
|
||||
|
||||
self.property_id.write({
|
||||
'is_done_split': True,
|
||||
'disassembly_information_ids': property_list
|
||||
})
|
||||
|
||||
class PropertySplitApprovalLine(models.Model):
|
||||
_name = 'property.split.approval.line'
|
||||
@@ -74,10 +160,7 @@ class PropertySplitApprovalLine(models.Model):
|
||||
|
||||
property_split_approval_id = fields.Many2one('property.split.approval', string='关联物业拆分审批')
|
||||
split_property = fields.Char(string='物业名称')
|
||||
split_units = fields.Char(string='单元')
|
||||
split_property_floor_id = fields.Many2one('property.floor.setting', string='楼层')
|
||||
split_asset_type_id = fields.Many2one('yuthon.resource.type', string='资产类型')
|
||||
split_building_area = fields.Float(string='建筑面积', digits=(16, 4))
|
||||
split_building_area = fields.Float(string='管理面积', digits=(16, 4))
|
||||
split_rent_area = fields.Float(string='可租面积', digits=(16, 4))
|
||||
split_remarks = fields.Char(string='备注')
|
||||
|
||||
|
||||
@@ -19,9 +19,9 @@
|
||||
<field name="arch" type="xml">
|
||||
<form string="物业拆分审批" create="0">
|
||||
<sheet>
|
||||
<!-- <header>-->
|
||||
<!-- <button name="put_split_message" type="object" string="按钮" class="oe_highlight"/>-->
|
||||
<!-- </header>-->
|
||||
<header>
|
||||
<button name="put_split_message" type="object" string="按钮" class="oe_highlight"/>
|
||||
</header>
|
||||
<widget name="web_ribbon" title="普件" bg_color="text-bg-success"
|
||||
invisible="urgency_level != 'normal'"/>
|
||||
<widget name="web_ribbon" title="急件" bg_color="text-bg-warning"
|
||||
@@ -74,13 +74,16 @@
|
||||
</group>
|
||||
<notebook>
|
||||
<page string="拆分信息">
|
||||
<field name="property_split_approval_line_ids">
|
||||
<field name="property_split_approval_line_ids"
|
||||
context="{
|
||||
'default_split_units': 'units',
|
||||
'default_split_property_floor_id': 'property_floor_id',
|
||||
'default_split_asset_type_id': 'asset_type_id ',
|
||||
}"
|
||||
>
|
||||
<tree editable="bottom">
|
||||
<field name="property_split_approval_id" column_invisible="1"/>
|
||||
<field name="split_property"/>
|
||||
<field name="split_units"/>
|
||||
<field name="split_property_floor_id"/>
|
||||
<field name="split_asset_type_id"/>
|
||||
<field name="split_building_area"/>
|
||||
<field name="split_rent_area"/>
|
||||
<field name="split_remarks"/>
|
||||
|
||||
@@ -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 +
|
||||
|
||||
Reference in New Issue
Block a user