pengyuthon wechat
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -52,6 +52,7 @@
|
||||
<field name="private_email" string="邮箱"/>
|
||||
<field name="private_phone" string="电话"/>
|
||||
<field name="pinyin_name"/>
|
||||
<field name="pinyin_min"/>
|
||||
<!-- 增加两个字段 -->
|
||||
<field name="user_salary"/>
|
||||
<field name="job_lv_salary"/>
|
||||
|
||||
Reference in New Issue
Block a user