添加功能
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from odoo import api, fields, models, _
|
||||
from pypinyin import pinyin,lazy_pinyin
|
||||
from odoo.osv import expression
|
||||
|
||||
|
||||
class YuthonUserRole(models.Model):
|
||||
@@ -18,6 +20,7 @@ class YuthonUserRole(models.Model):
|
||||
child_ids = fields.One2many('soong.user.role', 'parent_id', string='子集角色')
|
||||
yuthon_company = fields.Selection([('thtz', '天河投资集团'), ('thwg', '天河物管'),
|
||||
('thlc', '天河粮储'), ('thtjbb', '天河投资本部')], string="所属公司", compute='compute_company')
|
||||
pinyin_name = fields.Char(string="拼音名称", compute='_compute_pinyin', index=True, store=True)
|
||||
|
||||
@api.depends('department_id')
|
||||
def compute_company(self):
|
||||
@@ -38,4 +41,18 @@ class YuthonUserRole(models.Model):
|
||||
break
|
||||
department = department.parent_id
|
||||
else:
|
||||
record.yuthon_company = 'thtz'
|
||||
record.yuthon_company = 'thtz'
|
||||
|
||||
@api.depends('name')
|
||||
def _compute_pinyin(self):
|
||||
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)]
|
||||
domain = expression.AND([search_domain, domain])
|
||||
return self._search(domain, limit=limit, order=order)
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
<field name="name" required="1"/>
|
||||
<field name="user_type"/>
|
||||
<field name="department_id"/>
|
||||
<field name="pinyin_name" column_invisible="1"/>
|
||||
<field name="parent_id"/>
|
||||
<field name="child_ids" column_invisible="1"/>
|
||||
<field name="yuthon_company" readonly="0"/>
|
||||
|
||||
Reference in New Issue
Block a user