Skip to content

Commit

Permalink
[IMP] hr_timesheet_sheet: fix amount calculation issues + code simpli…
Browse files Browse the repository at this point in the history
…fication (OCA#211)

* [IMP] Fix amount calculation issues + code simplification

* [FIX] Fix employee_id related stuff

* [IMP] Ease customizations of message_subscribe_users

* [IMP] List view easier to read

* [IMP] Extra code simplification

* [IMP] Make use of batch create

* [FIX] Update company when onchange employee_id
  • Loading branch information
astirpe authored and sowrirajan committed Jun 10, 2024
1 parent 02004de commit 065fc3a
Show file tree
Hide file tree
Showing 11 changed files with 301 additions and 288 deletions.
9 changes: 4 additions & 5 deletions hr_timesheet_sheet/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ Timesheet entries are made by employees each day. At the end of the defined peri
employees validate their sheet and the manager must then approve his team's entries.
Periods are defined in the company forms and you can set them to run monthly, weekly or daily.

Negative hours are not admitted.

**Table of contents**

.. contents::
Expand All @@ -57,9 +55,9 @@ If you want other default ranges different from weekly, you need to go:
Known issues / Roadmap
======================

* When you open the `Summary` or `Details` tab, a save should be performed
to ensure the data shown is correct. This perhaps could be achieved by including
a .js file that does that.
* When you change values on the `Summary` tab, a save should be performed
to ensure the data shown on the `Details` tab is correct. This limitation could be
perhaps avoided by including a .js file that aligns the `Details` tab.
* The timesheet grid is limited to display a max. of 1M cells, due to a
limitation of the tree view limit parameter not being able to dynamically
set a limit. Since default value of odoo, 40 records is too small, we decided
Expand All @@ -82,6 +80,7 @@ Authors
~~~~~~~

* Eficent
* Onestein

Contributors
~~~~~~~~~~~~
Expand Down
4 changes: 3 additions & 1 deletion hr_timesheet_sheet/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
# Copyright 2018 Eficent
# Copyright 2018-2019 Brainbean Apps
# Copyright 2018-2019 Onestein (<https://www.onestein.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
'name': 'HR Timesheet Sheet',
'version': '12.0.1.0.7',
'version': '12.0.1.1.0',
'category': 'Human Resources',
'sequence': 80,
'summary': 'Timesheet Sheets, Activities',
'license': 'AGPL-3',
'author': (
'Eficent, '
'Onestein, '
'Odoo Community Association (OCA)'
),
'website': 'https://github.com/OCA/hr-timesheet',
Expand Down
61 changes: 34 additions & 27 deletions hr_timesheet_sheet/i18n/hr_timesheet_sheet.pot
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ msgid "Attachment Count"
msgstr ""

#. module: hr_timesheet_sheet
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:400
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:405
#, python-format
msgid "Cannot approve a non-submitted sheet."
msgstr ""
Expand Down Expand Up @@ -95,11 +95,6 @@ msgstr ""
msgid "Confirmed Timesheet Sheets"
msgstr ""

#. module: hr_timesheet_sheet
#: model:ir.model.fields,field_description:hr_timesheet_sheet.field_hr_timesheet_sheet_line__count_timesheets
msgid "Count Timesheets"
msgstr ""

#. module: hr_timesheet_sheet
#: model:ir.model.fields,field_description:hr_timesheet_sheet.field_hr_timesheet_sheet__create_uid
#: model:ir.model.fields,field_description:hr_timesheet_sheet.field_hr_timesheet_sheet_line__create_uid
Expand Down Expand Up @@ -175,12 +170,6 @@ msgstr ""
msgid "Employees"
msgstr ""

#. module: hr_timesheet_sheet
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:662
#, python-format
msgid "Error code: Cannot have 0 timesheets."
msgstr ""

#. module: hr_timesheet_sheet
#: model:ir.model.fields,field_description:hr_timesheet_sheet.field_hr_timesheet_sheet__message_follower_ids
msgid "Followers"
Expand Down Expand Up @@ -253,8 +242,8 @@ msgid "In Draft"
msgstr ""

#. module: hr_timesheet_sheet
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:328
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:342
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:332
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:347
#, python-format
msgid "In order to create a sheet for this employee, you must link him/her to an user."
msgstr ""
Expand Down Expand Up @@ -313,6 +302,11 @@ msgstr ""
msgid "My Timesheet Sheets"
msgstr ""

#. module: hr_timesheet_sheet
#: selection:hr_timesheet.sheet,state:0
msgid "New"
msgstr ""

#. module: hr_timesheet_sheet
#: model_terms:ir.actions.act_window,help:hr_timesheet_sheet.act_hr_timesheet_sheet_my_timesheets
msgid "New timesheet sheet."
Expand Down Expand Up @@ -369,13 +363,13 @@ msgid "Number of unread messages"
msgstr ""

#. module: hr_timesheet_sheet
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:398
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:403
#, python-format
msgid "Only an HR Officer or Manager can approve sheets."
msgstr ""

#. module: hr_timesheet_sheet
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:378
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:389
#, python-format
msgid "Only an HR Officer or Manager can refuse sheets or reset them to draft."
msgstr ""
Expand All @@ -392,6 +386,7 @@ msgstr ""

#. module: hr_timesheet_sheet
#: model_terms:ir.ui.view,arch_db:hr_timesheet_sheet.hr_timesheet_sheet_form
#: model_terms:ir.ui.view,arch_db:hr_timesheet_sheet.hr_timesheet_sheet_tree_simplified
msgid "Period"
msgstr ""

Expand Down Expand Up @@ -440,6 +435,12 @@ msgstr ""
msgid "Saturday"
msgstr ""

#. module: hr_timesheet_sheet
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:587
#, python-format
msgid "Save the Timesheet Sheet first."
msgstr ""

#. module: hr_timesheet_sheet
#: model_terms:ir.ui.view,arch_db:hr_timesheet_sheet.view_hr_timesheet_sheet_filter
msgid "Search Timesheet"
Expand Down Expand Up @@ -510,25 +511,25 @@ msgid "Task"
msgstr ""

#. module: hr_timesheet_sheet
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:203
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:206
#, python-format
msgid "The Company in the Timesheet Sheet and in the Department must be the same."
msgstr ""

#. module: hr_timesheet_sheet
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:193
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:196
#, python-format
msgid "The Company in the Timesheet Sheet and in the Employee must be the same."
msgstr ""

#. module: hr_timesheet_sheet
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:213
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:216
#, python-format
msgid "The Company in the Timesheet Sheet and in the Project must be the same."
msgstr ""

#. module: hr_timesheet_sheet
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:223
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:226
#, python-format
msgid "The Company in the Timesheet Sheet and in the Task must be the same."
msgstr ""
Expand All @@ -540,7 +541,7 @@ msgid "The range of your Timesheet Sheet."
msgstr ""

#. module: hr_timesheet_sheet
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:163
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:166
#, python-format
msgid "The start date cannot be later than the end date."
msgstr ""
Expand Down Expand Up @@ -684,6 +685,12 @@ msgstr ""
msgid "Waiting Approval"
msgstr ""

#. module: hr_timesheet_sheet
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:586
#, python-format
msgid "Warning"
msgstr ""

#. module: hr_timesheet_sheet
#: model:ir.model.fields,field_description:hr_timesheet_sheet.field_hr_timesheet_sheet__website_message_ids
msgid "Website Messages"
Expand All @@ -705,7 +712,7 @@ msgid "Week"
msgstr ""

#. module: hr_timesheet_sheet
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:354
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:359
#, python-format
msgid "Week %s"
msgstr ""
Expand All @@ -722,26 +729,26 @@ msgstr ""

#. module: hr_timesheet_sheet
#: code:addons/hr_timesheet_sheet/models/hr_department.py:41
#: code:addons/hr_timesheet_sheet/models/hr_employee.py:35
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:234
#: code:addons/hr_timesheet_sheet/models/hr_employee.py:36
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:236
#, python-format
msgid "You cannot change the company, as this %s (%s) is assigned to %s (%s)."
msgstr ""

#. module: hr_timesheet_sheet
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:365
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:370
#, python-format
msgid "You cannot delete a timesheet sheet which is already confirmed."
msgstr ""

#. module: hr_timesheet_sheet
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:320
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:323
#, python-format
msgid "You cannot duplicate a sheet."
msgstr ""

#. module: hr_timesheet_sheet
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:182
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:185
#, python-format
msgid "You cannot have 2 sheets that overlap!\n"
"Please use the menu 'Timesheet Sheet' to avoid this problem."
Expand Down
4 changes: 2 additions & 2 deletions hr_timesheet_sheet/models/account_analytic_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def _compute_sheet(self):
('date_start', '<=', timesheet.date),
('employee_id', '=', timesheet.employee_id.id),
('company_id', 'in', [timesheet.company_id.id, False]),
('state', '=', 'draft'),
('state', 'in', ['new', 'draft']),
], limit=1)
if timesheet.sheet_id != sheet:
timesheet.sheet_id = sheet
Expand Down Expand Up @@ -81,7 +81,7 @@ def _check_state(self):
if self.env.context.get('skip_check_state'):
return
for line in self:
if line.sheet_id and line.sheet_id.state != 'draft':
if line.sheet_id and line.sheet_id.state not in ['new', 'draft']:
raise UserError(
_('You cannot modify an entry in a confirmed '
'timesheet sheet.'))
Expand Down
5 changes: 3 additions & 2 deletions hr_timesheet_sheet/models/hr_employee.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ class HrEmployee(models.Model):

@api.multi
def _compute_timesheet_count(self):
Sheet = self.env['hr_timesheet.sheet']
for employee in self:
employee.timesheet_count = employee.env['hr_timesheet.sheet'].\
search_count([('employee_id', '=', employee.id)])
employee.timesheet_count = Sheet.search_count([
('employee_id', '=', employee.id)])

@api.constrains('company_id')
def _check_company_id(self):
Expand Down
Loading

0 comments on commit 065fc3a

Please sign in to comment.