Skip to content

Commit

Permalink
[FIX] hr_timesheet_sheet: sheet name
Browse files Browse the repository at this point in the history
  • Loading branch information
alexey-pelykh authored and dreispt committed Jan 21, 2024
1 parent 304b19e commit 4d5afe6
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 43 deletions.
2 changes: 1 addition & 1 deletion hr_timesheet_sheet/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

{
'name': 'HR Timesheet Sheet',
'version': '12.0.1.1.0',
'version': '12.0.1.1.1',
'category': 'Human Resources',
'sequence': 80,
'summary': 'Timesheet Sheets, Activities',
Expand Down
56 changes: 29 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:405
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:420
#, python-format
msgid "Cannot approve a non-submitted sheet."
msgstr ""
Expand Down Expand Up @@ -242,8 +242,8 @@ msgid "In Draft"
msgstr ""

#. module: hr_timesheet_sheet
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:332
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:347
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:355
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:370
#, 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 @@ -302,6 +302,11 @@ msgstr ""
msgid "My Timesheet Sheets"
msgstr ""

#. module: hr_timesheet_sheet
#: model:ir.model.fields,field_description:hr_timesheet_sheet.field_hr_timesheet_sheet__name
msgid "Name"
msgstr ""

#. module: hr_timesheet_sheet
#: selection:hr_timesheet.sheet,state:0
msgid "New"
Expand Down Expand Up @@ -332,11 +337,6 @@ msgstr ""
msgid "Next Activity Type"
msgstr ""

#. module: hr_timesheet_sheet
#: model:ir.model.fields,field_description:hr_timesheet_sheet.field_hr_timesheet_sheet__name
msgid "Note"
msgstr ""

#. module: hr_timesheet_sheet
#: model:ir.model.fields,field_description:hr_timesheet_sheet.field_hr_timesheet_sheet__message_needaction_counter
msgid "Number of Actions"
Expand All @@ -363,13 +363,13 @@ msgid "Number of unread messages"
msgstr ""

#. module: hr_timesheet_sheet
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:403
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:418
#, 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:389
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:404
#, python-format
msgid "Only an HR Officer or Manager can refuse sheets or reset them to draft."
msgstr ""
Expand Down Expand Up @@ -436,7 +436,7 @@ msgid "Saturday"
msgstr ""

#. module: hr_timesheet_sheet
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:587
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:602
#, python-format
msgid "Save the Timesheet Sheet first."
msgstr ""
Expand Down Expand Up @@ -511,25 +511,25 @@ msgid "Task"
msgstr ""

#. module: hr_timesheet_sheet
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:206
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:229
#, 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:196
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:219
#, 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:216
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:239
#, 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:226
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:249
#, python-format
msgid "The Company in the Timesheet Sheet and in the Task must be the same."
msgstr ""
Expand All @@ -541,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:166
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:189
#, python-format
msgid "The start date cannot be later than the end date."
msgstr ""
Expand Down Expand Up @@ -686,7 +686,7 @@ msgid "Waiting Approval"
msgstr ""

#. module: hr_timesheet_sheet
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:586
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:601
#, python-format
msgid "Warning"
msgstr ""
Expand All @@ -707,14 +707,10 @@ msgid "Wednesday"
msgstr ""

#. module: hr_timesheet_sheet
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:169
#: selection:res.company,sheet_range:0
msgid "Week"
msgstr ""

#. module: hr_timesheet_sheet
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:359
#, python-format
msgid "Week %s"
msgid "Week"
msgstr ""

#. module: hr_timesheet_sheet
Expand All @@ -727,28 +723,34 @@ msgstr ""
msgid "Week start day"
msgstr ""

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

#. module: hr_timesheet_sheet
#: code:addons/hr_timesheet_sheet/models/hr_department.py:41
#: code:addons/hr_timesheet_sheet/models/hr_employee.py:36
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:236
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:259
#, 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:370
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:385
#, 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:323
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:346
#, python-format
msgid "You cannot duplicate a sheet."
msgstr ""

#. module: hr_timesheet_sheet
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:185
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:208
#, python-format
msgid "You cannot have 2 sheets that overlap!\n"
"Please use the menu 'Timesheet Sheet' to avoid this problem."
Expand Down
2 changes: 1 addition & 1 deletion hr_timesheet_sheet/i18n/nl.po
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ msgstr "Week"
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:354
#, python-format
msgid "Week %s"
msgstr "Week %s"
msgstr ""

#. module: hr_timesheet_sheet
#: model:ir.model.fields,field_description:hr_timesheet_sheet.field_res_config_settings__timesheet_week_start
Expand Down
4 changes: 2 additions & 2 deletions hr_timesheet_sheet/i18n/nl_BE.po
Original file line number Diff line number Diff line change
Expand Up @@ -729,9 +729,9 @@ msgstr "Week"

#. module: hr_timesheet_sheet
#: code:addons/hr_timesheet_sheet/models/hr_timesheet_sheet.py:354
#, fuzzy, python-format
#, python-format
msgid "Week %s"
msgstr "Week"
msgstr ""

#. module: hr_timesheet_sheet
#: model:ir.model.fields,field_description:hr_timesheet_sheet.field_res_config_settings__timesheet_week_start
Expand Down
35 changes: 25 additions & 10 deletions hr_timesheet_sheet/models/hr_timesheet_sheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ def _default_employee(self):
], limit=1)

name = fields.Char(
string="Note",
states={'confirm': [('readonly', True)], 'done': [('readonly', True)]},
compute='_compute_name',
context_dependent=True,
)
employee_id = fields.Many2one(
comodel_name='hr.employee',
Expand Down Expand Up @@ -153,6 +153,29 @@ def _default_employee(self):
store=True,
)

@api.multi
@api.depends('date_start', 'date_end')
def _compute_name(self):
for sheet in self:
period_start = sheet.date_start.strftime(
'%V, %Y'
)
period_end = sheet.date_end.strftime(
'%V, %Y'
)

if period_start == period_end:
sheet.name = '%s %s' % (
_('Week'),
period_start,
)
else:
sheet.name = '%s %s - %s' % (
_('Weeks'),
period_start,
period_end,
)

@api.depends('timesheet_ids.unit_amount')
def _compute_total_time(self):
for sheet in self:
Expand Down Expand Up @@ -353,14 +376,6 @@ def write(self, vals):
rec.delete_empty_lines(True)
return res

@api.multi
def name_get(self):
# week number according to ISO 8601 Calendar
return [(r['id'], _('Week %s') % (str(
r['date_start'].isocalendar()[1])))
for r in self.sudo().read(['date_start'], load='_classic_write')]
# It's a cheesy name because you may have ranges different of weeks.

@api.multi
def unlink(self):
sheets = self.read(['state'])
Expand Down
10 changes: 10 additions & 0 deletions hr_timesheet_sheet/tests/test_hr_timesheet_sheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,3 +603,13 @@ def test_12_creating_sheet(self):
self.assertEqual(line.unit_amount, 2.0)
self.assertEqual(len(sheet.timesheet_ids), 1)
self.assertEqual(len(sheet.line_ids), 7)

def test_13(self):
sheet = self.sheet_model.sudo(self.user).create({
'company_id': self.user.company_id.id,
})

self.assertIsNotNone(sheet.name)

sheet.date_end = sheet.date_start + relativedelta(years=1)
self.assertIsNotNone(sheet.name)
3 changes: 1 addition & 2 deletions hr_timesheet_sheet/views/hr_timesheet_sheet_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<field name="arch" type="xml">
<tree decoration-info="state == 'draft'" decoration-muted="state == 'done'" decoration-bf="message_needaction == True" string="Timesheet Sheets">
<field name="employee_id"/>
<field name="display_name" string="Period"/>
<field name="name" string="Period"/>
<field name="date_start"/>
<field name="date_end"/>
<field name="department_id" invisible="1"/>
Expand Down Expand Up @@ -44,7 +44,6 @@
<group name="dates" string="Period">
<label for="date_start" string="Timesheet Period"/>
<div style="display: inline;"><field name="date_start" class="oe_inline"/> to <field name="date_end" class="oe_inline"/></div>
<field name="name" invisible="1"/>
<field name="department_id" invisible="1"/>
<field name="company_id" groups="base.group_multi_company"/>
</group>
Expand Down

0 comments on commit 4d5afe6

Please sign in to comment.