Skip to content

Commit 21f8deb

Browse files
committed
[ADD] hr_department_code
1 parent 318b936 commit 21f8deb

File tree

13 files changed

+620
-0
lines changed

13 files changed

+620
-0
lines changed

hr_department_code/README.rst

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
==================
2+
HR department code
3+
==================
4+
5+
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6+
!! This file is generated by oca-gen-addon-readme !!
7+
!! changes will be overwritten. !!
8+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
9+
10+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
11+
:target: https://odoo-community.org/page/development-status
12+
:alt: Beta
13+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
14+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
15+
:alt: License: AGPL-3
16+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fhr-lightgray.png?logo=github
17+
:target: https://github.com/OCA/hr/tree/14.0/hr_department_code
18+
:alt: OCA/hr
19+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
20+
:target: https://translation.odoo-community.org/projects/hr-14-0/hr-14-0-hr_department_code
21+
:alt: Translate me on Weblate
22+
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
23+
:target: https://runbot.odoo-community.org/runbot/116/14.0
24+
:alt: Try me on Runbot
25+
26+
|badge1| |badge2| |badge3| |badge4| |badge5|
27+
28+
This module add code in department.
29+
30+
**Table of contents**
31+
32+
.. contents::
33+
:local:
34+
35+
Bug Tracker
36+
===========
37+
38+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/hr/issues>`_.
39+
In case of trouble, please check there if your issue has already been reported.
40+
If you spotted it first, help us smashing it by providing a detailed and welcomed
41+
`feedback <https://github.com/OCA/hr/issues/new?body=module:%20hr_department_code%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
42+
43+
Do not contact contributors directly about support or help with technical issues.
44+
45+
Credits
46+
=======
47+
48+
Authors
49+
~~~~~~~
50+
51+
* Ecosoft
52+
53+
Contributors
54+
~~~~~~~~~~~~
55+
56+
* Saran Lim. <[email protected]>
57+
58+
Maintainers
59+
~~~~~~~~~~~
60+
61+
This module is maintained by the OCA.
62+
63+
.. image:: https://odoo-community.org/logo.png
64+
:alt: Odoo Community Association
65+
:target: https://odoo-community.org
66+
67+
OCA, or the Odoo Community Association, is a nonprofit organization whose
68+
mission is to support the collaborative development of Odoo features and
69+
promote its widespread use.
70+
71+
This module is part of the `OCA/hr <https://github.com/OCA/hr/tree/14.0/hr_department_code>`_ project on GitHub.
72+
73+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

hr_department_code/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
2+
3+
from . import models

hr_department_code/__manifest__.py

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright 2021 Ecosoft Co., Ltd. (http://ecosoft.co.th)
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
{
5+
"name": "HR department code",
6+
"version": "14.0.1.0.0",
7+
"license": "AGPL-3",
8+
"category": "Human Resources",
9+
"author": "Ecosoft, Odoo Community Association (OCA)",
10+
"website": "https://github.com/OCA/hr",
11+
"depends": ["hr"],
12+
"data": ["views/hr_department_views.xml"],
13+
"installable": True,
14+
"maintainer": ["Saran440"],
15+
}

hr_department_code/models/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
2+
3+
from . import hr_department
+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Copyright 2021 Ecosoft Co., Ltd. (http://ecosoft.co.th)
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
from odoo import api, fields, models
5+
6+
7+
class Department(models.Model):
8+
_inherit = "hr.department"
9+
_order = "code, name"
10+
11+
code = fields.Char()
12+
13+
def name_get(self):
14+
res = []
15+
for dep in self:
16+
name = dep.name
17+
if dep.code:
18+
name = ("[%(code)s] %(name)s") % {"code": dep.code, "name": name}
19+
res.append((dep.id, name))
20+
return res
21+
22+
@api.model
23+
def name_search(self, name, args=None, operator="ilike", limit=100):
24+
args = args or []
25+
domain = []
26+
if name:
27+
domain = ["|", ("code", operator, name), ("name", operator, name)]
28+
department = self.search(domain + args, limit=limit)
29+
return department.name_get()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* Saran Lim. <[email protected]>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This module add code in department.

0 commit comments

Comments
 (0)