mirror of
https://github.com/bringout/oca-technical.git
synced 2026-04-20 20:32:04 +02:00
Initial commit: OCA Technical packages (595 packages)
This commit is contained in:
commit
2cc02aac6e
24950 changed files with 2318079 additions and 0 deletions
|
|
@ -0,0 +1,3 @@
|
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from . import hr_department
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
# Copyright 2021 Ecosoft Co., Ltd. (http://ecosoft.co.th)
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class Department(models.Model):
|
||||
_inherit = "hr.department"
|
||||
_order = "code, name"
|
||||
|
||||
code = fields.Char()
|
||||
|
||||
def name_get(self):
|
||||
res = []
|
||||
for dep in self:
|
||||
name = dep.name
|
||||
if dep.code:
|
||||
name = ("[%(code)s] %(name)s") % {"code": dep.code, "name": name}
|
||||
res.append((dep.id, name))
|
||||
return res
|
||||
|
||||
@api.model
|
||||
def name_search(self, name, args=None, operator="ilike", limit=100):
|
||||
args = args or []
|
||||
domain = []
|
||||
if name:
|
||||
domain = ["|", ("code", operator, name), ("name", operator, name)]
|
||||
department = self.search(domain + args, limit=limit)
|
||||
return department.name_get()
|
||||
Loading…
Add table
Add a link
Reference in a new issue