Skip to content

Commit fb308fa

Browse files
authored
Merge pull request OCA#494 from brainbeanapps/12.0-add-hr_employee_document
[12.0][ADD] hr_employee_document: documents attached to the employee profile
2 parents f0f17b3 + 362217c commit fb308fa

File tree

11 files changed

+662
-0
lines changed

11 files changed

+662
-0
lines changed

hr_employee_document/README.rst

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
====================
2+
HR Employee Document
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/12.0/hr_employee_document
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-12-0/hr-12-0-hr_employee_document
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/12.0
24+
:alt: Try me on Runbot
25+
26+
|badge1| |badge2| |badge3| |badge4| |badge5|
27+
28+
This module allows to attach documents to the employee profile.
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_employee_document%0Aversion:%2012.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+
* Brainbean Apps
52+
53+
Contributors
54+
~~~~~~~~~~~~
55+
56+
* Alexey Pelykh <[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/12.0/hr_employee_document>`_ project on GitHub.
72+
73+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

hr_employee_document/__init__.py

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

hr_employee_document/__manifest__.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright 2018 Brainbean Apps (https://brainbeanapps.com)
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
3+
4+
{
5+
'name': 'HR Employee Document',
6+
'version': '12.0.1.0.0',
7+
'category': 'Human Resources',
8+
'website': 'https://github.com/OCA/hr',
9+
'author':
10+
'Brainbean Apps, '
11+
'Odoo Community Association (OCA)',
12+
'license': 'AGPL-3',
13+
'installable': True,
14+
'application': False,
15+
'summary': 'Documents attached to the employee profile',
16+
'depends': [
17+
'hr',
18+
'document',
19+
],
20+
'data': [
21+
'views/hr_employee.xml',
22+
],
23+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
2+
3+
from . import hr_employee
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Copyright 2018 Brainbean Apps (https://brainbeanapps.com)
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
3+
4+
from odoo import fields, models, api
5+
6+
7+
class HrEmployee(models.Model):
8+
_inherit = 'hr.employee'
9+
10+
document_ids = fields.One2many(
11+
'ir.attachment',
12+
compute='_compute_document_ids',
13+
groups='hr.group_hr_user',
14+
string='Documents',
15+
)
16+
documents_count = fields.Integer(
17+
compute='_compute_document_ids',
18+
groups='hr.group_hr_user',
19+
string='Document Count',
20+
)
21+
22+
def _compute_document_ids(self):
23+
attachments = self.env['ir.attachment'].search([
24+
('res_model', '=', self._name),
25+
('res_id', 'in', self.ids),
26+
])
27+
28+
result = dict.fromkeys(self.ids, self.env['ir.attachment'])
29+
for attachment in attachments:
30+
result[attachment.res_id] |= attachment
31+
32+
for employee in self:
33+
employee.document_ids = result[employee.id]
34+
employee.documents_count = len(employee.document_ids)
35+
36+
@api.multi
37+
def action_get_attachment_tree_view(self):
38+
action = self.env.ref('base.action_attachment').read()[0]
39+
action['context'] = {
40+
'default_res_model': self._name,
41+
'default_res_id': self.ids[0]
42+
}
43+
action['domain'] = str([
44+
('res_model', '=', self._name),
45+
('res_id', 'in', self.ids),
46+
])
47+
action['search_view_id'] = (
48+
self.env.ref('hr_employee_document.ir_attachment_view_search').id,
49+
)
50+
return action
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* Alexey Pelykh <[email protected]>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This module allows to attach documents to the employee profile.

0 commit comments

Comments
 (0)