Skip to content

Commit ddbd6ef

Browse files
alexey-pelykhErnesto Tejeda
authored and
Ernesto Tejeda
committed
[ADD] hr_timesheet_sheet: policies
1 parent 0179822 commit ddbd6ef

14 files changed

+809
-0
lines changed
+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
=============================================
2+
HR Timesheet Sheet: Department Manager Policy
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%2Ftimesheet-lightgray.png?logo=github
17+
:target: https://github.com/OCA/timesheet/tree/12.0/hr_timesheet_sheet_policy_department_manager
18+
:alt: OCA/timesheet
19+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
20+
:target: https://translation.odoo-community.org/projects/timesheet-12-0/timesheet-12-0-hr_timesheet_sheet_policy_department_manager
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/117/12.0
24+
:alt: Try me on Runbot
25+
26+
|badge1| |badge2| |badge3| |badge4| |badge5|
27+
28+
This module allows setting Department Manager as Reviewer on Timesheet Sheets.
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/timesheet/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/timesheet/issues/new?body=module:%20hr_timesheet_sheet_policy_department_manager%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/timesheet <https://github.com/OCA/timesheet/tree/12.0/hr_timesheet_sheet_policy_department_manager>`_ project on GitHub.
72+
73+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
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).
2+
3+
from . import models
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright 2019 Brainbean Apps (https://brainbeanapps.com)
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
{
5+
'name': 'HR Timesheet Sheet: Department Manager Policy',
6+
'version': '12.0.1.0.0',
7+
'author':
8+
'Brainbean Apps, '
9+
'Odoo Community Association (OCA)',
10+
'website': 'https://github.com/OCA/timesheet/',
11+
'license': 'AGPL-3',
12+
'category': 'Human Resources',
13+
'summary': 'Allows setting Department Manager as Reviewer',
14+
'depends': [
15+
'hr_timesheet_sheet',
16+
],
17+
'data': [
18+
'views/hr_timesheet_sheet.xml',
19+
],
20+
'installable': True,
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Translation of Odoo Server.
2+
# This file contains the translation of the following modules:
3+
# * hr_timesheet_sheet_policy_department_manager
4+
#
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: Odoo Server 12.0\n"
8+
"Report-Msgid-Bugs-To: \n"
9+
"Last-Translator: <>\n"
10+
"Language-Team: \n"
11+
"MIME-Version: 1.0\n"
12+
"Content-Type: text/plain; charset=UTF-8\n"
13+
"Content-Transfer-Encoding: \n"
14+
"Plural-Forms: \n"
15+
16+
#. module: hr_timesheet_sheet_policy_department_manager
17+
#: selection:res.company,timesheet_sheet_review_policy:0
18+
msgid "By Department Manager"
19+
msgstr ""
20+
21+
#. module: hr_timesheet_sheet_policy_department_manager
22+
#: selection:res.company,timesheet_sheet_review_policy:0
23+
msgid "By Direct Manager"
24+
msgstr ""
25+
26+
#. module: hr_timesheet_sheet_policy_department_manager
27+
#: selection:res.company,timesheet_sheet_review_policy:0
28+
msgid "By HR Manager/Officer"
29+
msgstr ""
30+
31+
#. module: hr_timesheet_sheet_policy_department_manager
32+
#: selection:res.company,timesheet_sheet_review_policy:0
33+
msgid "By Project Manager"
34+
msgstr ""
35+
36+
#. module: hr_timesheet_sheet_policy_department_manager
37+
#: model:ir.model,name:hr_timesheet_sheet_policy_department_manager.model_res_company
38+
msgid "Companies"
39+
msgstr ""
40+
41+
#. module: hr_timesheet_sheet_policy_department_manager
42+
#: model:ir.model.fields,help:hr_timesheet_sheet_policy_department_manager.field_res_company__timesheet_sheet_review_policy
43+
msgid "How Timesheet Sheets review is performed."
44+
msgstr ""
45+
46+
#. module: hr_timesheet_sheet_policy_department_manager
47+
#: code:addons/hr_timesheet_sheet_policy_department_manager/models/hr_timesheet_sheet.py:67
48+
#, python-format
49+
msgid "Only a Department's Manager can review the sheet."
50+
msgstr ""
51+
52+
#. module: hr_timesheet_sheet_policy_department_manager
53+
#: model:ir.model,name:hr_timesheet_sheet_policy_department_manager.model_hr_timesheet_sheet
54+
msgid "Timesheet Sheet"
55+
msgstr ""
56+
57+
#. module: hr_timesheet_sheet_policy_department_manager
58+
#: model:ir.model.fields,field_description:hr_timesheet_sheet_policy_department_manager.field_res_company__timesheet_sheet_review_policy
59+
msgid "Timesheet Sheet Review Policy"
60+
msgstr ""
61+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
2+
3+
from . import hr_timesheet_sheet
4+
from . import res_company
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Copyright 2019 Brainbean Apps (https://brainbeanapps.com)
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
3+
4+
from odoo import api, models, _
5+
from odoo.exceptions import UserError
6+
7+
import json
8+
from lxml import etree
9+
10+
11+
class HrTimesheetSheet(models.Model):
12+
_inherit = 'hr_timesheet.sheet'
13+
14+
@api.model
15+
def fields_view_get(self,
16+
view_id=None, view_type='form', toolbar=False,
17+
submenu=False):
18+
res = super().fields_view_get(
19+
view_id=view_id,
20+
view_type=view_type,
21+
toolbar=toolbar,
22+
submenu=submenu,
23+
)
24+
review_policy = self.env.user.company_id.timesheet_sheet_review_policy
25+
if review_policy == 'department_manager' and view_type == 'tree':
26+
view = etree.XML(res['arch'])
27+
field = view.find(".//field[@name='department_id']")
28+
if field is not None:
29+
field.set('invisible', '0')
30+
modifiers = json.loads(field.get('modifiers'))
31+
modifiers.update({
32+
'column_invisible': False,
33+
})
34+
field.set('modifiers', json.dumps(modifiers))
35+
res['arch'] = etree.tostring(
36+
view,
37+
encoding='unicode',
38+
).replace('\t', '')
39+
return res
40+
41+
@api.multi
42+
@api.depends('department_id.manager_id.user_id')
43+
def _compute_department_manager_as_reviewer(self):
44+
self._compute_possible_reviewer_ids()
45+
46+
@api.multi
47+
def _get_complete_name_components(self):
48+
self.ensure_one()
49+
result = super()._get_complete_name_components()
50+
if self.review_policy == 'department_manager':
51+
result += [self.department_id.name_get()[0][1]]
52+
return result
53+
54+
@api.multi
55+
def _get_possible_reviewers(self):
56+
self.ensure_one()
57+
if self.review_policy == 'department_manager':
58+
return self.department_id.manager_id.user_id
59+
return super()._get_possible_reviewers()
60+
61+
@api.multi
62+
def _check_can_review(self):
63+
super()._check_can_review()
64+
if self.filtered(
65+
lambda sheet: not sheet.can_review and
66+
sheet.review_policy == 'department_manager'):
67+
raise UserError(_(
68+
'Only a Department\'s Manager can review the sheet.'
69+
))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Copyright 2019 Brainbean Apps (https://brainbeanapps.com)
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
3+
4+
from odoo import fields, models
5+
6+
7+
class ResCompany(models.Model):
8+
_inherit = 'res.company'
9+
10+
timesheet_sheet_review_policy = fields.Selection(
11+
selection_add=[
12+
('department_manager', 'By Department Manager'),
13+
],
14+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* Alexey Pelykh <[email protected]>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This module allows setting Department Manager as Reviewer on Timesheet Sheets.
Loading

0 commit comments

Comments
 (0)