From 2b34ac4adc33ce8e91ae27f0c1f52c43333b7ec1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?=
<9664676+pengyuthon@user.noreply.gitee.com>
Date: Mon, 22 Dec 2025 14:18:49 +0800
Subject: [PATCH 1/2] =?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
---
.../models/soong_workflow_record.py | 4 +-
.../models/inherit_hr_leave_allocation.py | 2 +-
.../wizard/leave_allocation_wizard.py | 53 ++++++++-----
.../views/yuthon_vacation_reports_views.xml | 4 +-
.../views/yuthon_service_approval_views.xml | 1 +
.../models/processing_order_approval.py | 30 ++++----
.../models/property_report_repair.py | 5 +-
.../views/processing_order_approval_views.xml | 2 +-
.../views/property_report_repair.xml | 2 +-
.../models/inherit_hr_payroll_structure.py | 10 ++-
.../inherit_hr_payroll_structure_views.xml | 36 ++++++++-
yuthon_salary/wizard/yuthon_payroll_wizard.py | 63 +++------------
yuthon_salary/wizard/yuthon_salary_wizard.py | 76 +++++++++++++------
yuthon_work_brand/views/hr_menus.xml | 6 ++
14 files changed, 177 insertions(+), 117 deletions(-)
diff --git a/soong_workflow/models/soong_workflow_record.py b/soong_workflow/models/soong_workflow_record.py
index c99f6e6bb..3abce0cdc 100644
--- a/soong_workflow/models/soong_workflow_record.py
+++ b/soong_workflow/models/soong_workflow_record.py
@@ -352,8 +352,8 @@ class SoongWorkflowRecord(models.Model):
for record in record_ids:
record_id = record.env[record.res_model].search([('id', '=', record.res_id)])
record_list.append(record.id)
- # if record_id.log_ids and self.env.user.name != "Administrator":
- # raise UserError("当前流程不可删除")
+ if record_id.log_ids and self.env.user.name != "Administrator":
+ raise UserError("当前流程不可删除")
wizard = self.env.ref("soong_workflow.view_soong_workflow_record_delete_wizard")
return {
"name": _("删除确认"),
diff --git a/yuthon_holiday/models/inherit_hr_leave_allocation.py b/yuthon_holiday/models/inherit_hr_leave_allocation.py
index 6717528d7..a6d96804f 100644
--- a/yuthon_holiday/models/inherit_hr_leave_allocation.py
+++ b/yuthon_holiday/models/inherit_hr_leave_allocation.py
@@ -179,7 +179,7 @@ class HrLeaveAllocation(models.Model):
def update_vacation(self):
leave_ids = self.env["hr.leave.allocation"].browse(
self._context.get('active_ids', self._context.get('active_id')))
- date = datetime(2025, 10, 1) # 修改为你的日期
+ date = datetime(2025, 12, 1) # 修改为你的日期
for leave in leave_ids:
leave_list = []
compensatory_list = []
diff --git a/yuthon_holiday/wizard/leave_allocation_wizard.py b/yuthon_holiday/wizard/leave_allocation_wizard.py
index c3c9e12ab..59b193e7d 100644
--- a/yuthon_holiday/wizard/leave_allocation_wizard.py
+++ b/yuthon_holiday/wizard/leave_allocation_wizard.py
@@ -36,27 +36,42 @@ class LeaveAllocationWizard(models.Model):
holiday_status_id1 = self.env['hr.leave.type'].search([('name', '=', '补休')], limit=1)
accrual_plan_id = self.env['hr.leave.accrual.plan'].search([('name', '=', '年假(天河物管)')], limit=1)
if row[1].value and int(row[1].value) != 0:
- number_of_days_display = int(row[1].value) / 8
- self.env['hr.leave.allocation'].create({
- 'employee_id': employee_id.id,
- 'name': '年假公司分配',
- 'number_of_days': number_of_days_display,
- 'employee_ids': [(6, 0, [employee_id.id])],
- 'holiday_status_id': holiday_status_id.id,
- 'accrual_plan_id': accrual_plan_id.id,
- 'allocation_type': 'accrual',
- "number_of_days_display": number_of_days_display,
- 'notes': '年假公司分配'
- })
+ number_of_days_display = int(row[1].value)
+ allocation_id = self.env['hr.leave.allocation'].search([('employee_id', '=', employee_id.id),
+ ('holiday_status_id', '=', holiday_status_id.id)])
+ if allocation_id:
+ allocation_id.write({
+ 'number_of_days': number_of_days_display
+ })
+ else:
+ self.env['hr.leave.allocation'].create({
+ 'employee_id': employee_id.id,
+ 'name': '年假公司分配',
+ 'number_of_days': number_of_days_display,
+ 'employee_ids': [(6, 0, [employee_id.id])],
+ 'holiday_status_id': holiday_status_id.id,
+ 'accrual_plan_id': accrual_plan_id.id,
+ 'allocation_type': 'accrual',
+ 'date_from': datetime(2025, 1, 1),
+ 'notes': '年假公司分配'
+ })
if row[2].value and int(row[2].value) != 0:
- self.env['hr.leave.allocation'].create({
- 'holiday_status_id': holiday_status_id1.id,
- 'employee_id': employee_id.id,
- 'name': '补休',
- 'employee_ids': [(6, 0, [employee_id.id])],
- 'number_of_hours_display': int(row[2].value)
- })
+ allocation_id = self.env['hr.leave.allocation'].search([('employee_id', '=', employee_id.id),
+ ('holiday_status_id', '=', holiday_status_id1.id)])
+ if allocation_id:
+ allocation_id.write({
+ 'number_of_hours': int(row[2].value),
+ })
+ else:
+ self.env['hr.leave.allocation'].create({
+ 'holiday_status_id': holiday_status_id1.id,
+ 'employee_id': employee_id.id,
+ 'name': '补休',
+ 'date_from': datetime(2025, 12, 1),
+ 'employee_ids': [(6, 0, [employee_id.id])],
+ 'number_of_hours_display': int(row[2].value)
+ })
diff --git a/yuthon_hr_attendance/views/yuthon_vacation_reports_views.xml b/yuthon_hr_attendance/views/yuthon_vacation_reports_views.xml
index 12e670032..5098603cf 100644
--- a/yuthon_hr_attendance/views/yuthon_vacation_reports_views.xml
+++ b/yuthon_hr_attendance/views/yuthon_vacation_reports_views.xml
@@ -4,7 +4,7 @@
yuthon.vacation.reports.tree
yuthon.vacation.reports
-
+
@@ -452,7 +452,7 @@
考勤确认单台账
yuthon.vacation.reports
tree,form
- {'search_default_group_by_employee_id': 1, 'search_default_group_by_vacation_year': True, 'search_default_group_by_vacation_month': True}
+ {'search_default_group_by_employee_id': 1, 'search_default_group_by_vacation_month': True}
diff --git a/yuthon_hr_employee_approval/views/yuthon_service_approval_views.xml b/yuthon_hr_employee_approval/views/yuthon_service_approval_views.xml
index ddc73c278..10aa4fb62 100644
--- a/yuthon_hr_employee_approval/views/yuthon_service_approval_views.xml
+++ b/yuthon_hr_employee_approval/views/yuthon_service_approval_views.xml
@@ -50,6 +50,7 @@
+
diff --git a/yuthon_maintain/models/processing_order_approval.py b/yuthon_maintain/models/processing_order_approval.py
index b6a6f7bbd..1a425d4f1 100644
--- a/yuthon_maintain/models/processing_order_approval.py
+++ b/yuthon_maintain/models/processing_order_approval.py
@@ -91,13 +91,16 @@ class ProcessingOrderApproval(models.Model):
],
limit=1
)
+ else:
+ record.contract_id = False
+
if contract_id and contract_id.lease_id:
record.contract_id = contract_id.lease_id.id
else:
- record.contract_id = None
+ record.contract_id = False
@api.onchange('repair_id')
- def _onchange_repair_id(self):
+ def onchange_repair_id(self):
if self.repair_id:
self.property_id = self.repair_id.property_id
self.lessee_id = self.repair_id.lessee_id
@@ -143,16 +146,17 @@ class ProcessingOrderApproval(models.Model):
def end_approval(self):
for rec in self:
- menu_id = self.env['ir.ui.menu'].search([('name', '=', '处理单')])
- url = f'https://oa.thtzjt.com/web#id={self.id}&cids=2&action={menu_id.action.id}&model=processing.order.approval&view_type=list&menu_id={menu_id.id}'
- self.sudo().env["wecom.apps"].sync_send_message_textcard(category='oa',
- user_id=rec.applicant_id.employee_id.wecom_userid,
- title="处理单",
- description="你有一份已处理的报时报修",
- url=url, btntxt="详细信息")
- if rec.device_id:
- rec.device_id.report_state = 'done'
- else:
- rec.repair_id.report_state = 'done'
+ if rec.processing_results in ['done', 'part']:
+ menu_id = self.env['ir.ui.menu'].search([('name', '=', '处理单审批')])
+ url = f'https://oa.thtzjt.com/web#id={self.id}&cids=2&action={menu_id.action.id}&model=processing.order.approval&view_type=list&menu_id={menu_id.id}'
+ if rec.device_id:
+ rec.device_id.report_state = 'done'
+ else:
+ rec.repair_id.report_state = 'done'
+ self.sudo().env["wecom.apps"].sync_send_message_textcard(category='oa',
+ user_id=rec.applicant_id.employee_id.wecom_userid,
+ title="处理单",
+ description="你有一份已处理的报时报修",
+ url=url, btntxt="详细信息")
diff --git a/yuthon_maintain/models/property_report_repair.py b/yuthon_maintain/models/property_report_repair.py
index f229bc25c..8cec20bbe 100644
--- a/yuthon_maintain/models/property_report_repair.py
+++ b/yuthon_maintain/models/property_report_repair.py
@@ -20,7 +20,6 @@ class PropertyRentRelief(models.Model):
lessee_id = fields.Many2one('property.tenant.information', string="承租方")
contact = fields.Char(string="联系人")
phone = fields.Char( string="联系电话")
- leader_id = fields.Many2one('res.users', string="负责人")
types_repairs = fields.Selection([('hydropower', '水电维修'), ('building', '门窗维修'), ('other', '其他维修')], string='维修类型')
problem_description = fields.Text(string="问题描述")
remake = fields.Text(string="备注")
@@ -33,7 +32,7 @@ class PropertyRentRelief(models.Model):
self_users_ids = fields.Many2many('res.users', string="当前经办人",
default=lambda self: [(6, 0, [self.env.user.id])])
create_time = fields.Date(string="填报日期", default=fields.Datetime.now)
- processing_order_id = fields.Many2one('processing.order.approval', string="处理单流程")
+ processing_order_id = fields.Many2one('processing.order.approval', string="处理单")
def _get_default_name_title(self):
return self._description if self._description else self._name
@@ -73,8 +72,10 @@ class PropertyRentRelief(models.Model):
'repair_id': self.id,
'applicant_id': self.users_id.id,
'name': self.problem_description,
+ 'problem_description': self.problem_description,
'code': self.env['ir.sequence'].next_by_code('property_report_repair_code'),
})
+ order_id.onchange_repair_id()
workflow_record_id = self.env['soong.workflow.record'].search([
('code', '=', self.code),
])
diff --git a/yuthon_maintain/views/processing_order_approval_views.xml b/yuthon_maintain/views/processing_order_approval_views.xml
index ac5c066f9..a2a1c4e9a 100644
--- a/yuthon_maintain/views/processing_order_approval_views.xml
+++ b/yuthon_maintain/views/processing_order_approval_views.xml
@@ -9,8 +9,8 @@
-
+
diff --git a/yuthon_maintain/views/property_report_repair.xml b/yuthon_maintain/views/property_report_repair.xml
index 447a3fe9c..1f75d9501 100644
--- a/yuthon_maintain/views/property_report_repair.xml
+++ b/yuthon_maintain/views/property_report_repair.xml
@@ -7,9 +7,9 @@
+
-
diff --git a/yuthon_salary/models/inherit_hr_payroll_structure.py b/yuthon_salary/models/inherit_hr_payroll_structure.py
index facc430c5..46324284f 100644
--- a/yuthon_salary/models/inherit_hr_payroll_structure.py
+++ b/yuthon_salary/models/inherit_hr_payroll_structure.py
@@ -11,7 +11,7 @@ class HrPayrollStructure(models.Model):
company_id = fields.Many2one('res.company', string="公司", default=lambda self: self.env.company)
yuthon_company = fields.Selection([('thtz', 'thtz')], default="thtz")
type_id = fields.Many2one('hr.payroll.structure.type', string="职级类型")
- level_id = fields.Many2one('yuthon.payroll.type.setting', string="级别")
+ level_id = fields.Many2one('yuthon.payroll.type.setting', string="职级类别")
lv_name = fields.Char(related='level_id.name', string='级别名称', store=True)
name = fields.Char(string="职级名称")
sequence = fields.Char(string='级别序号', store=True)
@@ -256,6 +256,14 @@ class HrPayrollStructure(models.Model):
payroll.end_time = dec_2025_start
payroll.is_enable = False
+ def two_time(self):
+ dec_2025_start = datetime(2025, 11, 1).date()
+ payroll_ids = self.env["hr.payroll.structure"].browse(
+ self._context.get('active_ids', self._context.get('active_id')))
+ for payroll in payroll_ids:
+ payroll.create_time = dec_2025_start
+ payroll.is_enable = True
+
def rank_log_time(self):
"""定时任务:根据日志记录的生效时间更新主模型字段值"""
# 出发一下
diff --git a/yuthon_salary/views/inherit_hr_payroll_structure_views.xml b/yuthon_salary/views/inherit_hr_payroll_structure_views.xml
index cd55abf6a..bfcadc715 100644
--- a/yuthon_salary/views/inherit_hr_payroll_structure_views.xml
+++ b/yuthon_salary/views/inherit_hr_payroll_structure_views.xml
@@ -28,6 +28,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ hr.payroll.structure.history.tree
+ hr.payroll.structure
+
+
@@ -38,7 +56,7 @@
-
+
@@ -113,7 +131,16 @@
职级
hr.payroll.structure
tree,form,search
+ [('is_enable', '=', True)]
{'search_default_is_enable':1}
+
+
+ 历史职级
+ hr.payroll.structure
+ tree,form,search
+ [('is_enable', '=', False)]
+ {'search_default_group_lv_id': 1}
+
批量更新职级类型
@@ -178,4 +205,11 @@
code
action = model.onetime()
+
+ 一次性
+
+
+ code
+ action = model.two_time()
+
\ No newline at end of file
diff --git a/yuthon_salary/wizard/yuthon_payroll_wizard.py b/yuthon_salary/wizard/yuthon_payroll_wizard.py
index e6395491a..a29f90429 100644
--- a/yuthon_salary/wizard/yuthon_payroll_wizard.py
+++ b/yuthon_salary/wizard/yuthon_payroll_wizard.py
@@ -60,54 +60,15 @@ class YuthonPayrollWizard(models.Model):
})
def yuthon_payroll_lc_data(self, row):
- # 1. 获取传入的行数据
- type_name = row[0].value
- base_salary = float(row[1].value) if row[1].value else 0.0
- rank_salary = float(row[2].value) if row[2].value else 0.0
- advance_performance_bonuses = float(row[3].value) if row[3].value else 0.0
-
- # 2. 查询薪资结构类型
- type_id = self.env['hr.payroll.structure.type'].search([('name', '=', type_name)], limit=1)
- if not type_id:
- # 可选:添加日志提示类型不存在
- self.env.user.notify_warning(message=f"未找到薪资结构类型:{type_name}")
- return
-
- # 3. 查找“天河粮储”公司的任意hr.payroll.structure记录
- # 先找到公司(根据公司名称搜索,可替换为公司编码更精准)
- target_company = self.env['res.company'].search([('name', '=', '天河粮储')], limit=1)
- if not target_company:
- self.env.user.notify_warning(message="未找到名称为「天河粮储」的公司")
- return
-
- source_structure = self.env['hr.payroll.structure'].search(
- [('company_id.name', '=', target_company.id)],
- limit=1 # 取任意一条
- )
- copied_salary_rules = []
- source_salary_rules = source_structure.rule_ids
- for rule in source_salary_rules:
- rule_vals = rule.copy_data()[0]
- for field in ['id', 'create_uid', 'create_date', 'write_uid', 'write_date']:
- rule_vals.pop(field, None)
- copied_salary_rules.append((0, 0, rule_vals))
-
- new_structure = self.env['hr.payroll.structure'].create({
- 'name': type_name,
- 'type_id': type_id.id,
- 'company_id': target_company.id,
- 'rule_ids': copied_salary_rules,
- })
- salary_rule_mapping = {
- '基本工资': base_salary,
- '职级工资': rank_salary,
- '预发绩效奖金': advance_performance_bonuses
- }
- for rule_name, target_value in salary_rule_mapping.items():
- target_rule = new_structure.rule_ids.search(
- [('name', '=', rule_name), ('structure_id', '=', new_structure.id)],
- limit=1
- )
- if target_rule:
- target_rule.write({'amount_fix': target_value})
-
+ type_id = self.env['hr.payroll.structure.type'].search([('name', '=', row[0].value)], limit=1)
+ base_salary = row[1].value
+ rank_salary = row[2].value
+ advance_performance_bonuses = row[3].value
+ payroll_id = self.env['hr.payroll.structure'].search(
+ [('type_id', '=', type_id.id)])
+ if payroll_id:
+ payroll_id.write({
+ 'base_salary': base_salary,
+ 'rank_salary': rank_salary,
+ 'advance_performance_bonuses': advance_performance_bonuses,
+ })
\ No newline at end of file
diff --git a/yuthon_salary/wizard/yuthon_salary_wizard.py b/yuthon_salary/wizard/yuthon_salary_wizard.py
index 836951de4..24bb6b87e 100644
--- a/yuthon_salary/wizard/yuthon_salary_wizard.py
+++ b/yuthon_salary/wizard/yuthon_salary_wizard.py
@@ -81,37 +81,67 @@ class YuthonSalaryWizard(models.Model):
}
salary_name.create(salary_date)
struct_id.write({'default_struct_id': structure_id.id})
- def salary_lc_data(self, row, salary_dates):
- salary_name = self.env['hr.salary.rule']
- text = row[2].value
+
+ # def salary_lc_data(self, row, salary_dates):
+ # salary_name = self.env['hr.salary.rule']
+ # text = row[2].value
+ # struct_id = self.env['hr.payroll.structure.type'].search([
+ # ('name', '=', text),
+ # ])
+ # if not struct_id:
+ # struct_id = self.env['hr.payroll.structure.type'].create({
+ # 'name': text,
+ # 'sequence': row[0].value})
+ # structure_id = self.env['hr.payroll.structure'].search([('name', '=', text)])
+ # level_id = self.env['yuthon.payroll.type.setting'].search([('name', '=', row[1].value)],
+ # )
+ # if not structure_id:
+ # structure_id = self.env['hr.payroll.structure'].create({
+ # 'name': text,
+ # 'level_id':level_id.id,
+ # 'type_id':struct_id.id,
+ # 'sequence': row[0].value,})
+ # struct_id.write({'default_struct_id': structure_id.id})
+ # for salary, r in zip(salary_dates, row[3:11]):
+ # name_pinyin = pinyin(salary.value, style=Style.FIRST_LETTER)
+ # abbreviation = "".join([p[0][0] for p in name_pinyin]).upper()
+ # salary_date = {
+ # 'sequence': row[0].value,
+ # 'name': salary.value, # 姓名
+ # 'struct_id': structure_id.id,
+ # 'amount_select': 'fix',
+ # 'amount_fix': r.value,
+ # }
+ # salary_name.create(salary_date)
+
+ def salary_lc_data(self, row, rx):
+ text = row[0].value
+ company_id = self.env['res.company'].search([('name', '=', '天河粮储')], limit=1)
+ structure_id = self.env['hr.payroll.structure'].search([('name', '=', text)])
+ level_id = self.env['yuthon.payroll.type.setting'].search([('name', '=', row[4].value),
+ ('company_id', '=', company_id.id)
+ ])
+ if not level_id:
+ level_id = self.env['yuthon.payroll.type.setting'].create({
+ 'sequence': rx,
+ 'name': row[4].value,
+ 'company_id': company_id.id,
+ })
struct_id = self.env['hr.payroll.structure.type'].search([
('name', '=', text),
])
if not struct_id:
struct_id = self.env['hr.payroll.structure.type'].create({
'name': text,
- 'sequence': row[0].value})
- structure_id = self.env['hr.payroll.structure'].search([('name', '=', text)])
- level_id = self.env['yuthon.payroll.type.setting'].search([('name', '=', row[1].value)],
- )
+ 'sequence': rx})
if not structure_id:
- structure_id = self.env['hr.payroll.structure'].create({
+ self.env['hr.payroll.structure'].create({
'name': text,
- 'level_id':level_id.id,
- 'type_id':struct_id.id,
- 'sequence': row[0].value,})
- struct_id.write({'default_struct_id': structure_id.id})
- for salary, r in zip(salary_dates, row[3:11]):
- name_pinyin = pinyin(salary.value, style=Style.FIRST_LETTER)
- abbreviation = "".join([p[0][0] for p in name_pinyin]).upper()
- salary_date = {
- 'sequence': row[0].value,
- 'name': salary.value, # 姓名
- 'struct_id': structure_id.id,
- 'amount_select': 'fix',
- 'amount_fix': r.value,
- }
- salary_name.create(salary_date)
+ 'type_id': struct_id.id,
+ 'level_id': level_id.id,
+ 'company_id': company_id.id,
+ 'create_time': datetime(2025, 11, 1).date(),
+ 'sequence': rx, })
def salary_wg_data(self, row, salary_dates):
salary_name = self.env['hr.salary.rule']
diff --git a/yuthon_work_brand/views/hr_menus.xml b/yuthon_work_brand/views/hr_menus.xml
index 37dc338d0..279d78039 100644
--- a/yuthon_work_brand/views/hr_menus.xml
+++ b/yuthon_work_brand/views/hr_menus.xml
@@ -397,6 +397,12 @@
parent="human_payroll_items_root_board"
action="yuthon_salary.action_view_hr_payroll_structure_list_form"
sequence="15"/>
+