From f284ce4b989bcc7cd973144dfd66dc2154f50201 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?= Date: Fri, 29 Nov 2024 17:32:11 +0800 Subject: [PATCH] pengyuthon wechat --- yuthon_hr_employee/models/yuthon_hr_employee.py | 7 ++++--- yuthon_hr_employee/views/yuthon_hr_employee_views.xml | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/yuthon_hr_employee/models/yuthon_hr_employee.py b/yuthon_hr_employee/models/yuthon_hr_employee.py index e9e3fc6d0..e422a5b99 100644 --- a/yuthon_hr_employee/models/yuthon_hr_employee.py +++ b/yuthon_hr_employee/models/yuthon_hr_employee.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from dateutil.relativedelta import relativedelta -from pypinyin import pinyin,lazy_pinyin +from pypinyin import pinyin, lazy_pinyin, STYLE_FIRST_LETTER from odoo.osv import expression from odoo import api, fields, models from datetime import date, datetime @@ -118,7 +118,7 @@ class YuthonHrEmployee(models.Model): skills_certificates_ids = fields.One2many('yuthon.skills.certificates.line', 'employee_id', string="教育经历明细行") pinyin_name = fields.Char(string="拼音名称", compute='_compute_pinyin', index=True, store=True) - # pinyin_min = fields.Char(string='拼音缩写', compute='_compute_pinyin', index=True, store=True) + pinyin_min = fields.Char(string='拼音缩写', compute='_compute_pinyin', index=True, store=True) @api.depends('department_id') def compute_company(self): @@ -293,13 +293,14 @@ class YuthonHrEmployee(models.Model): def _compute_pinyin(self): for employee in self: employee.pinyin_name = ''.join(lazy_pinyin(employee.name)) + employee.pinyin_min = ''.join(lazy_pinyin(employee.name, style=STYLE_FIRST_LETTER)) @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)] + search_domain = ['|', '|', ('pinyin_name', operator, input_pinyin), ('name', operator, name), ('pinyin_min', operator, input_pinyin)] domain = expression.AND([search_domain, domain]) return self._search(domain, limit=limit, order=order) diff --git a/yuthon_hr_employee/views/yuthon_hr_employee_views.xml b/yuthon_hr_employee/views/yuthon_hr_employee_views.xml index c87db3fa1..d273535b6 100644 --- a/yuthon_hr_employee/views/yuthon_hr_employee_views.xml +++ b/yuthon_hr_employee/views/yuthon_hr_employee_views.xml @@ -52,6 +52,7 @@ +