Skip to content

Commit f4671ef

Browse files
AdriaGForgeFlowJuany Davila
authored and
Juany Davila
committed
Migrate module hr_timesheet_sheet_period to v12
1 parent f6a1401 commit f4671ef

13 files changed

+542
-91
lines changed

Diff for: hr_timesheet_sheet_period/README.rst

+47-24
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,39 @@
1-
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
2-
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
3-
:alt: License: AGPL-3
4-
51
==========================================
62
HR Timesheet Sheet based on Payroll Period
73
==========================================
84

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--timesheet-lightgray.png?logo=github
17+
:target: https://github.com/OCA/hr-timesheet/tree/12.0/hr_timesheet_sheet_period
18+
:alt: OCA/hr-timesheet
19+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
20+
:target: https://translation.odoo-community.org/projects/hr-timesheet-12-0/hr-timesheet-12-0-hr_timesheet_sheet_period
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+
928
This module allows to create timesheets with start and end dates matching with the
10-
payroll period of the schedule pay that is specified in the contract of the
29+
payroll period of the schedule pay that is specified in the contract of the
1130
employee or if not then will match the nearest payroll period.
1231

32+
**Table of contents**
33+
34+
.. contents::
35+
:local:
36+
1337
Configuration
1438
=============
1539

@@ -21,48 +45,47 @@ Usage
2145

2246
When the user goes to 'Human Resources > Time Tracking > My current
2347
timesheet', the application will attempt to create a new timesheet using
24-
start and end dates of the Pay Period corresponding to today's date
48+
start and end dates of the Pay Period corresponding to today's date
2549
as per the Schedule Pay mentioned in the Employee's contract.
2650

27-
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
28-
:alt: Try me on Runbot
29-
:target: https://runbot.odoo-community.org/runbot/117/10.0
30-
31-
3251
Bug Tracker
3352
===========
3453

35-
Bugs are tracked on `GitHub Issues
36-
<https://github.com/OCA/hr-timesheet/issues>`_. In case of trouble, please
37-
check there if your issue has already been reported. If you spotted it first,
38-
help us smashing it by providing a detailed and welcomed feedback.
54+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/hr-timesheet/issues>`_.
55+
In case of trouble, please check there if your issue has already been reported.
56+
If you spotted it first, help us smashing it by providing a detailed and welcomed
57+
`feedback <https://github.com/OCA/hr-timesheet/issues/new?body=module:%20hr_timesheet_sheet_period%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
3958

59+
Do not contact contributors directly about support or help with technical issues.
4060

4161
Credits
4262
=======
4363

44-
Images
45-
------
64+
Authors
65+
~~~~~~~
4666

47-
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.
67+
* Eficent Business and IT Consulting Services S.L.
68+
* Serpent Consulting Services Pvt. Ltd.
4869

4970
Contributors
50-
------------
71+
~~~~~~~~~~~~
5172

5273
* Jordi Ballester Alomar <[email protected]>
5374
* Serpent Consulting Services Pvt. Ltd. <[email protected]>
5475

55-
Maintainer
56-
----------
76+
Maintainers
77+
~~~~~~~~~~~
78+
79+
This module is maintained by the OCA.
5780

5881
.. image:: https://odoo-community.org/logo.png
5982
:alt: Odoo Community Association
6083
:target: https://odoo-community.org
6184

62-
This module is maintained by the OCA.
63-
6485
OCA, or the Odoo Community Association, is a nonprofit organization whose
6586
mission is to support the collaborative development of Odoo features and
6687
promote its widespread use.
6788

68-
To contribute to this module, please visit https://odoo-community.org.
89+
This module is part of the `OCA/hr-timesheet <https://github.com/OCA/hr-timesheet/tree/12.0/hr_timesheet_sheet_period>`_ project on GitHub.
90+
91+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

Diff for: hr_timesheet_sheet_period/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
# -*- coding: utf-8 -*-
1+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
22

33
from . import models

Diff for: hr_timesheet_sheet_period/__manifest__.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
# -*- coding: utf-8 -*-
21
# Copyright 2016-17 Eficent Business and IT Consulting Services S.L.
32
# Copyright 2016-17 Serpent Consulting Services Pvt. Ltd.
43
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
54

65
{
76
'name': "HR Timesheet Sheet based on Payroll Period",
8-
'version': '10.0.1.0.0',
7+
'version': '12.0.1.0.0',
98
'category': 'Human Resources',
109
"author": "Eficent Business and IT Consulting Services S.L., "
1110
"Serpent Consulting Services Pvt. Ltd., "
1211
"Odoo Community Association (OCA)",
13-
'website': 'http://www.eficent.com',
12+
'website': 'https://github.com/OCA/hr-timesheet',
1413
'license': 'AGPL-3',
1514
"depends": ['hr_period', 'hr_timesheet_sheet'],
1615
"data": [

Diff for: hr_timesheet_sheet_period/models/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
# -*- coding: utf-8 -*-
1+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
22

33
from . import hr_timesheet_sheet

Diff for: hr_timesheet_sheet_period/models/hr_timesheet_sheet.py

+39-35
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,59 @@
1-
# -*- coding: utf-8 -*-
21
# Copyright 2016-17 Eficent Business and IT Consulting Services S.L.
32
# Copyright 2016-17 Serpent Consulting Services Pvt. Ltd.
43
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
54

65
from datetime import datetime
76
from odoo import api, fields, models, _
8-
from odoo.exceptions import ValidationError as UserError
7+
from odoo.exceptions import ValidationError
8+
from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT
99

1010

1111
class HrTimesheetSheet(models.Model):
12-
_inherit = "hr_timesheet_sheet.sheet"
12+
_inherit = "hr_timesheet.sheet"
1313

1414
@api.model
15-
def _default_date_from(self):
16-
res = super(HrTimesheetSheet, self)._default_date_from()
15+
def _default_date_start(self):
16+
res = super(HrTimesheetSheet, self)._default_date_start()
1717
period = self._get_current_pay_period()
18-
if period:
19-
return period.date_start
20-
else:
21-
return res
18+
return period and period.date_start or res
2219

2320
@api.model
24-
def _default_date_to(self):
25-
res = super(HrTimesheetSheet, self)._default_date_to()
21+
def _default_date_end(self):
22+
res = super(HrTimesheetSheet, self)._default_date_end()
2623
period = self._get_current_pay_period()
27-
if period:
28-
return period.date_end
29-
else:
30-
return res
24+
return period and period.date_end or res
3125

3226
@api.model
3327
def _default_hr_period_id(self):
3428
return self._get_current_pay_period()
3529

36-
hr_period_id = fields.Many2one('hr.period', string='Pay Period',
37-
readonly=True,
38-
states={'new': [('readonly', False)]},
39-
default=_default_hr_period_id)
40-
date_from = fields.Date('Date from', required=True, index=True,
41-
readonly=True,
42-
states={'new': [('readonly', False)]},
43-
default=_default_date_from)
44-
date_to = fields.Date('Date to', required=True, index=True, readonly=True,
45-
states={'new': [('readonly', False)]},
46-
default=_default_date_to)
30+
hr_period_id = fields.Many2one(
31+
'hr.period',
32+
string='Pay Period',
33+
readonly=True,
34+
states={'draft': [('readonly', False)]},
35+
default=_default_hr_period_id
36+
)
37+
date_start = fields.Date(
38+
string='Date From',
39+
default=lambda self: self._default_date_start(),
40+
required=True,
41+
index=True,
42+
states={'draft': [('readonly', False)]},
43+
)
44+
date_end = fields.Date(
45+
string='Date To',
46+
default=lambda self: self._default_date_end(),
47+
required=True,
48+
index=True,
49+
states={'draft': [('readonly', False)]},
50+
)
4751

4852
@api.multi
4953
def name_get(self):
5054
if not self._ids:
5155
return []
52-
if isinstance(self._ids, (long, int)):
56+
if isinstance(self._ids, int):
5357
self._ids = [self._ids]
5458
res = super(HrTimesheetSheet, self).name_get()
5559
res2 = []
@@ -68,15 +72,15 @@ def name_get(self):
6872
@api.onchange('hr_period_id')
6973
def onchange_pay_period(self):
7074
if self.hr_period_id:
71-
self.date_from = self.hr_period_id.date_start
72-
self.date_to = self.hr_period_id.date_end
75+
self.date_start = self.hr_period_id.date_start
76+
self.date_end = self.hr_period_id.date_end
7377
self.name = self.hr_period_id.name
7478

7579
@api.model
7680
def _get_current_pay_period(self):
7781
period_obj = self.env['hr.period']
7882
contract_obj = self.env['hr.contract']
79-
date_today = datetime.today().strftime('%Y-%m-%d')
83+
date_today = datetime.today().strftime(DEFAULT_SERVER_DATETIME_FORMAT)
8084
employee = self.default_get(['employee_id'])
8185
contract = contract_obj.search([('employee_id', '=',
8286
employee.get('employee_id'))])
@@ -91,18 +95,18 @@ def _get_current_pay_period(self):
9195
return False
9296

9397
@api.multi
94-
@api.constrains('date_from', 'date_to', 'hr_period_id')
98+
@api.constrains('date_start', 'date_end', 'hr_period_id')
9599
def _check_start_end_dates(self):
96100
for timesheet in self:
97101
if timesheet.hr_period_id:
98-
if timesheet.date_from != timesheet.hr_period_id.date_start:
99-
raise UserError(
102+
if timesheet.date_start != timesheet.hr_period_id.date_start:
103+
raise ValidationError(
100104
_("The Date From of Timesheet must match with that of"
101105
" date start '%s' of the Payroll period '%s'.") % (
102106
timesheet.hr_period_id.date_start,
103107
timesheet.hr_period_id.name))
104-
if timesheet.date_to != timesheet.hr_period_id.date_end:
105-
raise UserError(
108+
if timesheet.date_end != timesheet.hr_period_id.date_end:
109+
raise ValidationError(
106110
_("The Date To of Timesheet must match with that of"
107111
" date stop '%s' of the Payroll period '%s'.") % (
108112
timesheet.hr_period_id.date_end,

Diff for: hr_timesheet_sheet_period/readme/CONFIGURE.rst

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Create first the Payroll Fiscal Years and Payroll
2+
Periods from 'Human Resources > Configuration > Payroll'

Diff for: hr_timesheet_sheet_period/readme/CONTRIBUTORS.rst

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
* Jordi Ballester Alomar <[email protected]>
2+
* Serpent Consulting Services Pvt. Ltd. <[email protected]>

Diff for: hr_timesheet_sheet_period/readme/DESCRIPTION.rst

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
This module allows to create timesheets with start and end dates matching with the
2+
payroll period of the schedule pay that is specified in the contract of the
3+
employee or if not then will match the nearest payroll period.

Diff for: hr_timesheet_sheet_period/readme/USAGE.rst

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
When the user goes to 'Human Resources > Time Tracking > My current
2+
timesheet', the application will attempt to create a new timesheet using
3+
start and end dates of the Pay Period corresponding to today's date
4+
as per the Schedule Pay mentioned in the Employee's contract.

0 commit comments

Comments
 (0)