diff --git a/hr_timesheet_sheet/__manifest__.py b/hr_timesheet_sheet/__manifest__.py index 5a3589b11..52e35f726 100644 --- a/hr_timesheet_sheet/__manifest__.py +++ b/hr_timesheet_sheet/__manifest__.py @@ -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', diff --git a/hr_timesheet_sheet/i18n/hr_timesheet_sheet.pot b/hr_timesheet_sheet/i18n/hr_timesheet_sheet.pot index 5ef05f33f..3cc59cc19 100644 --- a/hr_timesheet_sheet/i18n/hr_timesheet_sheet.pot +++ b/hr_timesheet_sheet/i18n/hr_timesheet_sheet.pot @@ -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 "" @@ -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 "" @@ -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" @@ -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" @@ -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 "" @@ -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 "" @@ -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 "" @@ -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 "" @@ -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 "" @@ -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 @@ -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." diff --git a/hr_timesheet_sheet/i18n/nl.po b/hr_timesheet_sheet/i18n/nl.po index 7c9b54b52..d85b21f22 100644 --- a/hr_timesheet_sheet/i18n/nl.po +++ b/hr_timesheet_sheet/i18n/nl.po @@ -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 diff --git a/hr_timesheet_sheet/i18n/nl_BE.po b/hr_timesheet_sheet/i18n/nl_BE.po index 993c23b3c..894b3a05b 100644 --- a/hr_timesheet_sheet/i18n/nl_BE.po +++ b/hr_timesheet_sheet/i18n/nl_BE.po @@ -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 diff --git a/hr_timesheet_sheet/models/hr_timesheet_sheet.py b/hr_timesheet_sheet/models/hr_timesheet_sheet.py index 8e5fb04fa..69b79018a 100644 --- a/hr_timesheet_sheet/models/hr_timesheet_sheet.py +++ b/hr_timesheet_sheet/models/hr_timesheet_sheet.py @@ -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', @@ -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: @@ -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']) diff --git a/hr_timesheet_sheet/tests/test_hr_timesheet_sheet.py b/hr_timesheet_sheet/tests/test_hr_timesheet_sheet.py index 2a5128e77..761f0e702 100644 --- a/hr_timesheet_sheet/tests/test_hr_timesheet_sheet.py +++ b/hr_timesheet_sheet/tests/test_hr_timesheet_sheet.py @@ -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) diff --git a/hr_timesheet_sheet/views/hr_timesheet_sheet_views.xml b/hr_timesheet_sheet/views/hr_timesheet_sheet_views.xml index 5c2167ce2..107f97d53 100644 --- a/hr_timesheet_sheet/views/hr_timesheet_sheet_views.xml +++ b/hr_timesheet_sheet/views/hr_timesheet_sheet_views.xml @@ -10,7 +10,7 @@ - + @@ -44,7 +44,6 @@