From 35b8d96d7a7905d8dfb1a30a718b586b7b11c8d9 Mon Sep 17 00:00:00 2001
From: zhou <123@>
Date: Mon, 12 May 2025 17:09:52 +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
---
soong_workflow/models/soong_hr_employee.py | 1 +
soong_workflow/models/soong_user_role.py | 11 ++++-
.../models/soong_workflow_record.py | 32 +++++++++++++-
.../views/soong_hr_employee_views.xml | 42 +++++++++----------
.../views/soong_workflow_record.xml | 3 +-
.../models/yuthon_hr_department.py | 12 ++++--
.../models/yuthon_hr_employee.py | 11 ++++-
yuthon_will_task/models/yuthon_will_task.py | 1 +
.../views/yuthon_will_task_views.xml | 1 +
9 files changed, 83 insertions(+), 31 deletions(-)
diff --git a/soong_workflow/models/soong_hr_employee.py b/soong_workflow/models/soong_hr_employee.py
index 6528f8894..f81dfb1da 100644
--- a/soong_workflow/models/soong_hr_employee.py
+++ b/soong_workflow/models/soong_hr_employee.py
@@ -8,6 +8,7 @@ class YuthonHrEmployee(models.Model):
user_role_id = fields.Many2one('soong.user.role', string="主角色")
user_role_ids = fields.Many2many('soong.user.role', string="辅助角色")
department_ids = fields.Many2many('hr.department', string="辅助部门")
+ bank_account = fields.Char()
@api.onchange('user_role_id')
def _onchange_user_role_id(self):
diff --git a/soong_workflow/models/soong_user_role.py b/soong_workflow/models/soong_user_role.py
index bf91a3a56..e2fe0f5a1 100644
--- a/soong_workflow/models/soong_user_role.py
+++ b/soong_workflow/models/soong_user_role.py
@@ -41,8 +41,15 @@ class YuthonUserRole(models.Model):
def _name_search(self, name, domain=None, operator='ilike', limit=None, order=None):
domain = domain or []
if name:
- input_pinyin = ''.join(lazy_pinyin(name))
- search_domain = ['|', ('pinyin_name', operator, input_pinyin), ('name', operator, name)]
+ has_chinese = any('\u4e00' <= char <= '\u9fff' for char in name)
+ if has_chinese:
+ # 包含中文:使用模糊匹配
+ search_domain = [('name', operator, name)]
+ else:
+ # 纯字母/数字:使用精确匹配
+ search_domain = ['|',
+ ('pinyin_name', operator, name),
+ ('name', '=', name)]
domain = expression.AND([search_domain, domain])
return self._search(domain, limit=limit, order=order)
diff --git a/soong_workflow/models/soong_workflow_record.py b/soong_workflow/models/soong_workflow_record.py
index 31623a49a..6a86a4cdd 100644
--- a/soong_workflow/models/soong_workflow_record.py
+++ b/soong_workflow/models/soong_workflow_record.py
@@ -22,7 +22,6 @@ class SoongWorkflowRecord(models.Model):
re.name = res_name
return super(SoongWorkflowRecord, self).read(fields=fields, load=load)
-
name = fields.Char(string="名称")
code = fields.Char(string="流水号")
write_date2 = fields.Datetime(string="最后更新日期", readoly="1")
@@ -37,8 +36,37 @@ class SoongWorkflowRecord(models.Model):
approvals_group_id = fields.Many2one(related='workflow_id.approvals_group_id', string="审批分组", store=True)
department_id = fields.Many2one("hr.department", string="部门", required=True)
done_by = fields.Many2one(comodel_name="res.users", string="发起人")
- # is_department_record = fields.Boolean(string="是否是本部门数据", index=True)
active = fields.Boolean(string="归档", default=True)
+ member_of_department = fields.Boolean("是否是本部门数据", compute='_compute_part_of_department', search='_search_part_of_department')
+
+ @api.depends_context('uid', 'company')
+ @api.depends('department_id')
+ def _compute_part_of_department(self):
+ user_employee = self._get_valid_employee_for_user()
+ active_department = user_employee.department_id
+ for employee in self:
+ employee.member_of_department = employee.department_id == active_department
+
+ def _get_valid_employee_for_user(self):
+ user = self.env.user
+ employee = user.employee_ids
+ if not employee:
+ user_employees = user.employee_id.sudo().search([
+ ('user_id', '=', user.id)
+ ])
+ employee = user_employees.filtered(lambda r: r.company_id == user.company_id) or user_employees[:1]
+ return employee
+ #
+ def _search_part_of_department(self, operator, value):
+ if operator not in ('=', '!=') or not isinstance(value, bool):
+ raise UserError(_('Operation not supported'))
+ user_employee = self._get_valid_employee_for_user()
+ # Double negation
+ if not value:
+ operator = '!=' if operator == '=' else '='
+ if not user_employee.department_id:
+ return [('id', operator, user_employee.id)]
+ return (['!'] if operator == '!=' else []) + [('department_id', '=', user_employee.department_id.id)]
# def get_department_employees(self, department_id):
# valid_user_ids = set()
diff --git a/soong_workflow/views/soong_hr_employee_views.xml b/soong_workflow/views/soong_hr_employee_views.xml
index 1df8e2584..d1991d7a9 100644
--- a/soong_workflow/views/soong_hr_employee_views.xml
+++ b/soong_workflow/views/soong_hr_employee_views.xml
@@ -15,26 +15,26 @@
-
- view.employee.inherit.tree.soong
- hr.employee
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
- inherit.view.employee.filter
- hr.employee
-
-
-
- parent_id
- multi
-
-
-
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/soong_workflow/views/soong_workflow_record.xml b/soong_workflow/views/soong_workflow_record.xml
index a2e7aa349..d15d2f235 100644
--- a/soong_workflow/views/soong_workflow_record.xml
+++ b/soong_workflow/views/soong_workflow_record.xml
@@ -8,6 +8,7 @@
+
@@ -34,7 +35,7 @@
-
+
diff --git a/yuthon_hr_employee/models/yuthon_hr_department.py b/yuthon_hr_employee/models/yuthon_hr_department.py
index 047bcb878..b0f0f1322 100644
--- a/yuthon_hr_employee/models/yuthon_hr_department.py
+++ b/yuthon_hr_employee/models/yuthon_hr_department.py
@@ -58,13 +58,19 @@ class YuthonHrDepartment(models.Model):
for employee in self:
employee.pinyin_name = ''.join(lazy_pinyin(employee.name))
-
@api.model
def _name_search(self, name, domain=None, operator='ilike', limit=None, order=None):
domain = domain or []
if name:
- input_pinyin = ''.join(lazy_pinyin(name))
- search_domain = ['|', ('pinyin_name', operator, input_pinyin), ('name', operator, name)]
+ has_chinese = any('\u4e00' <= char <= '\u9fff' for char in name)
+ if has_chinese:
+ # 包含中文:使用模糊匹配
+ search_domain = [('name', operator, name)]
+ else:
+ # 纯字母/数字:使用精确匹配
+ search_domain = ['|',
+ ('pinyin_name', operator, name),
+ ('name', '=', name)]
domain = expression.AND([search_domain, domain])
return self._search(domain, limit=limit, order=order)
diff --git a/yuthon_hr_employee/models/yuthon_hr_employee.py b/yuthon_hr_employee/models/yuthon_hr_employee.py
index 2246b928c..de5fb62b4 100644
--- a/yuthon_hr_employee/models/yuthon_hr_employee.py
+++ b/yuthon_hr_employee/models/yuthon_hr_employee.py
@@ -447,8 +447,15 @@ class YuthonHrEmployee(models.Model):
def _name_search(self, name, domain=None, operator='ilike', limit=None, order=None):
domain = domain or []
if name:
- input_pinyin = ''.join(lazy_pinyin(name))
- search_domain = ['|', '|', ('pinyin_name', operator, input_pinyin), ('name', operator, name), ('pinyin_min', operator, input_pinyin)]
+ has_chinese = any('\u4e00' <= char <= '\u9fff' for char in name)
+ if has_chinese:
+ # 包含中文:使用模糊匹配
+ search_domain = [('name', operator, name)]
+ else:
+ # 纯字母/数字:使用精确匹配
+ search_domain = ['|',
+ ('pinyin_name', operator, name),
+ ('name', '=', name)]
domain = expression.AND([search_domain, domain])
return self._search(domain, limit=limit, order=order)
diff --git a/yuthon_will_task/models/yuthon_will_task.py b/yuthon_will_task/models/yuthon_will_task.py
index e5e766581..6f28857fa 100644
--- a/yuthon_will_task/models/yuthon_will_task.py
+++ b/yuthon_will_task/models/yuthon_will_task.py
@@ -16,6 +16,7 @@ class YuthonWillTask(models.Model):
priority = fields.Selection([('general', '不紧急不重要'), ('important', '重要不紧急'),
('urgent', '紧急不重要'), ('very_urgent', '重要且紧急')], string='优先级')
user_id = fields.Many2one('res.users', string="创建人", default=lambda self: self.env.user)
+ company_id = fields.Many2one('res.company', string="公司", default=lambda self: self.env.company)
task_content = fields.Text(string='任务内容')
remarks = fields.Text(string='备注')
creation_time = fields.Date(string='创建时间', default=fields.Date.today())
diff --git a/yuthon_will_task/views/yuthon_will_task_views.xml b/yuthon_will_task/views/yuthon_will_task_views.xml
index 376364231..10cf483e2 100644
--- a/yuthon_will_task/views/yuthon_will_task_views.xml
+++ b/yuthon_will_task/views/yuthon_will_task_views.xml
@@ -136,6 +136,7 @@
+
From bec16df79d9c06e2675df21e7ca2f9d1c27e4f25 Mon Sep 17 00:00:00 2001
From: zhou <123@>
Date: Mon, 12 May 2025 17:16:25 +0800
Subject: [PATCH 2/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
---
yuthon_hr_attendance/wizard/attendance_correct_wizard.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/yuthon_hr_attendance/wizard/attendance_correct_wizard.py b/yuthon_hr_attendance/wizard/attendance_correct_wizard.py
index 7006a0b5c..ff858b734 100644
--- a/yuthon_hr_attendance/wizard/attendance_correct_wizard.py
+++ b/yuthon_hr_attendance/wizard/attendance_correct_wizard.py
@@ -24,12 +24,12 @@ class AttendanceCorrectWizard(models.TransientModel):
min_hour_from = record.attendance_id.employee_id.resource_id.calendar_id.attendance_ids[0].hour_from
min_hour = int(min_hour_from)
min_minute = int(min_hour_from * 10 % min_hour_from)
- will_datetime_start = current_date.replace(year=year, month=month, day=day, hour=min_hour, minute=min_minute) - timedelta(hours=8)
+ will_datetime_start = current_date.replace(year=year, month=month, day=day, hour=min_hour, minute=min_minute) - timedelta(hours=7)
record.attendance_id.write({'check_in': will_datetime_start, 'is_approval': True, 'is_abnormal':False, 'is_no_card':False, 'is_early_card':False, 'is_late_card':False})
max_hour_to = record.attendance_id.employee_id.resource_id.calendar_id.attendance_ids[-1].hour_to
max_hour = int(max_hour_to)
max_minute = int(max_hour_to * 10 % max_hour_to)
- will_datetime_end = current_date.replace(year=year, month=month, day=day, hour=max_hour, minute=max_minute) - timedelta(hours=8)
+ will_datetime_end = current_date.replace(year=year, month=month, day=day, hour=max_hour, minute=max_minute) - timedelta(hours=7)
record.attendance_id.write({'check_out': will_datetime_end, 'is_approval': True, 'is_abnormal':False, 'is_no_card':False, 'is_early_card':False, 'is_late_card':False, 'absenteeism_card':False})
else:
check_in_start = record.attendance_id.shift_id.template_id.check_in_start