From aa1156a36b39494be52e8a3527a8ec8f9b117592 Mon Sep 17 00:00:00 2001 From: "David Alonso (Solvos)" Date: Tue, 1 Oct 2019 18:19:27 +0200 Subject: [PATCH 01/16] [ADD] maintenance_timesheet --- maintenance_timesheet/README.rst | 73 +++ maintenance_timesheet/__init__.py | 1 + maintenance_timesheet/__manifest__.py | 24 + .../data/demo_maintenance_timesheet.xml | 44 ++ maintenance_timesheet/i18n/es.po | 69 +++ .../i18n/maintenance_timesheet.pot | 63 +++ maintenance_timesheet/models/__init__.py | 3 + maintenance_timesheet/models/hr_timesheet.py | 47 ++ .../models/maintenance_equipment.py | 13 + .../models/maintenance_request.py | 51 +++ maintenance_timesheet/readme/CONTRIBUTORS.rst | 1 + maintenance_timesheet/readme/DESCRIPTION.rst | 1 + .../maintenance_timesheet_security.xml | 26 ++ .../static/description/icon.png | Bin 0 -> 9455 bytes .../static/description/index.html | 419 ++++++++++++++++++ maintenance_timesheet/tests/__init__.py | 1 + .../tests/test_maintenance_timesheet.py | 71 +++ .../views/hr_timesheet_views.xml | 49 ++ .../views/maintenance_request_views.xml | 75 ++++ 19 files changed, 1031 insertions(+) create mode 100644 maintenance_timesheet/README.rst create mode 100644 maintenance_timesheet/__init__.py create mode 100644 maintenance_timesheet/__manifest__.py create mode 100644 maintenance_timesheet/data/demo_maintenance_timesheet.xml create mode 100644 maintenance_timesheet/i18n/es.po create mode 100644 maintenance_timesheet/i18n/maintenance_timesheet.pot create mode 100644 maintenance_timesheet/models/__init__.py create mode 100644 maintenance_timesheet/models/hr_timesheet.py create mode 100644 maintenance_timesheet/models/maintenance_equipment.py create mode 100644 maintenance_timesheet/models/maintenance_request.py create mode 100644 maintenance_timesheet/readme/CONTRIBUTORS.rst create mode 100644 maintenance_timesheet/readme/DESCRIPTION.rst create mode 100644 maintenance_timesheet/security/maintenance_timesheet_security.xml create mode 100644 maintenance_timesheet/static/description/icon.png create mode 100644 maintenance_timesheet/static/description/index.html create mode 100644 maintenance_timesheet/tests/__init__.py create mode 100644 maintenance_timesheet/tests/test_maintenance_timesheet.py create mode 100644 maintenance_timesheet/views/hr_timesheet_views.xml create mode 100644 maintenance_timesheet/views/maintenance_request_views.xml diff --git a/maintenance_timesheet/README.rst b/maintenance_timesheet/README.rst new file mode 100644 index 000000000..fb201201c --- /dev/null +++ b/maintenance_timesheet/README.rst @@ -0,0 +1,73 @@ +====================== +Maintenance Timesheets +====================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fmaintenance-lightgray.png?logo=github + :target: https://github.com/OCA/maintenance/tree/12.0/maintenance_timesheet + :alt: OCA/maintenance +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/maintenance-12-0/maintenance-12-0-maintenance_timesheet + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/240/12.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module adds timesheets to a request. + +**Table of contents** + +.. contents:: + :local: + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Solvos + +Contributors +~~~~~~~~~~~~ + +* David Alonso + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/maintenance `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/maintenance_timesheet/__init__.py b/maintenance_timesheet/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/maintenance_timesheet/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/maintenance_timesheet/__manifest__.py b/maintenance_timesheet/__manifest__.py new file mode 100644 index 000000000..8aa1247e6 --- /dev/null +++ b/maintenance_timesheet/__manifest__.py @@ -0,0 +1,24 @@ +# © 2019 Solvos Consultoría Informática () +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html +{ + "name": "Maintenance Timesheets", + "summary": "Adds timesheets to maintenance requests", + "author": "Odoo Community Association (OCA), Solvos", + "license": "AGPL-3", + "version": "12.0.1.0.1", + "category": "Human Resources", + "website": "https://github.com/OCA/maintenance", + "depends": [ + "maintenance_project", + "hr_timesheet", + ], + "data": [ + "security/maintenance_timesheet_security.xml", + "views/hr_timesheet_views.xml", + "views/maintenance_request_views.xml", + ], + "demo": [ + "data/demo_maintenance_timesheet.xml", + ], + 'installable': True, +} diff --git a/maintenance_timesheet/data/demo_maintenance_timesheet.xml b/maintenance_timesheet/data/demo_maintenance_timesheet.xml new file mode 100644 index 000000000..8c49ea205 --- /dev/null +++ b/maintenance_timesheet/data/demo_maintenance_timesheet.xml @@ -0,0 +1,44 @@ + + + + + + + + + Corrective #1 for Generic Monitor + + + + + + corrective + + + + + Request tasks done + + + + + + + + + + + + + + + Touchpad repaired + + + + + + + + + diff --git a/maintenance_timesheet/i18n/es.po b/maintenance_timesheet/i18n/es.po new file mode 100644 index 000000000..63c0c413c --- /dev/null +++ b/maintenance_timesheet/i18n/es.po @@ -0,0 +1,69 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * maintenance_timesheet +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2019-10-04 08:28+0000\n" +"PO-Revision-Date: 2019-11-13 11:35+0000\n" +"Last-Translator: David Alonso (Solvos) \n" +"Language-Team: \n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 3.8\n" + +#. module: maintenance_timesheet +#: model_terms:ir.ui.view,arch_db:maintenance_timesheet.hr_equipment_request_view_form +msgid "Hours" +msgstr "horas" + +#. module: maintenance_timesheet +#: model_terms:ir.ui.view,arch_db:maintenance_timesheet.hr_equipment_request_view_kanban +msgid "Hours" +msgstr "horas" + +#. module: maintenance_timesheet +#: model:ir.model,name:maintenance_timesheet.model_account_analytic_line +msgid "Analytic Line" +msgstr "Cuenta analítica" + +#. module: maintenance_timesheet +#: code:addons/maintenance_timesheet/models/hr_timesheet.py:46 +#, python-format +msgid "" +"Cannot save or delete a timesheet for a maintenance request already done" +msgstr "" +"No se puede editar o borrar un parte de trabajo de una petición de " +"mantenimiento ya finalizada" + +#. module: maintenance_timesheet +#: model:ir.model,name:maintenance_timesheet.model_maintenance_equipment +msgid "Maintenance Equipment" +msgstr "Equipo" + +#. module: maintenance_timesheet +#: model:ir.model,name:maintenance_timesheet.model_maintenance_request +#: model:ir.model.fields,field_description:maintenance_timesheet.field_account_analytic_line__maintenance_request_id +msgid "Maintenance Request" +msgstr "Petición de mantenimiento" + +#. module: maintenance_timesheet +#: model_terms:ir.ui.view,arch_db:maintenance_timesheet.hr_timesheet_line_search +msgid "Request" +msgstr "Petición" + +#. module: maintenance_timesheet +#: model:ir.model.fields,field_description:maintenance_timesheet.field_maintenance_request__timesheet_total_hours +msgid "Timesheet Total Hours" +msgstr "Horas totales en partes de trabajo" + +#. module: maintenance_timesheet +#: model:ir.actions.act_window,name:maintenance_timesheet.timesheet_action_from_request +#: model:ir.model.fields,field_description:maintenance_timesheet.field_maintenance_request__timesheet_ids +msgid "Timesheets" +msgstr "Partes de trabajo" diff --git a/maintenance_timesheet/i18n/maintenance_timesheet.pot b/maintenance_timesheet/i18n/maintenance_timesheet.pot new file mode 100644 index 000000000..dd1ecd266 --- /dev/null +++ b/maintenance_timesheet/i18n/maintenance_timesheet.pot @@ -0,0 +1,63 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * maintenance_timesheet +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: maintenance_timesheet +#: model_terms:ir.ui.view,arch_db:maintenance_timesheet.hr_equipment_request_view_form +msgid "Hours" +msgstr "" + +#. module: maintenance_timesheet +#: model_terms:ir.ui.view,arch_db:maintenance_timesheet.hr_equipment_request_view_kanban +msgid "Hours" +msgstr "" + +#. module: maintenance_timesheet +#: model:ir.model,name:maintenance_timesheet.model_account_analytic_line +msgid "Analytic Line" +msgstr "" + +#. module: maintenance_timesheet +#: code:addons/maintenance_timesheet/models/hr_timesheet.py:46 +#, python-format +msgid "Cannot save or delete a timesheet for a maintenance request already done" +msgstr "" + +#. module: maintenance_timesheet +#: model:ir.model,name:maintenance_timesheet.model_maintenance_equipment +msgid "Maintenance Equipment" +msgstr "" + +#. module: maintenance_timesheet +#: model:ir.model,name:maintenance_timesheet.model_maintenance_request +#: model:ir.model.fields,field_description:maintenance_timesheet.field_account_analytic_line__maintenance_request_id +msgid "Maintenance Request" +msgstr "" + +#. module: maintenance_timesheet +#: model_terms:ir.ui.view,arch_db:maintenance_timesheet.hr_timesheet_line_search +msgid "Request" +msgstr "" + +#. module: maintenance_timesheet +#: model:ir.model.fields,field_description:maintenance_timesheet.field_maintenance_request__timesheet_total_hours +msgid "Timesheet Total Hours" +msgstr "" + +#. module: maintenance_timesheet +#: model:ir.actions.act_window,name:maintenance_timesheet.timesheet_action_from_request +#: model:ir.model.fields,field_description:maintenance_timesheet.field_maintenance_request__timesheet_ids +msgid "Timesheets" +msgstr "" + diff --git a/maintenance_timesheet/models/__init__.py b/maintenance_timesheet/models/__init__.py new file mode 100644 index 000000000..b7f7bd17c --- /dev/null +++ b/maintenance_timesheet/models/__init__.py @@ -0,0 +1,3 @@ +from . import hr_timesheet +from . import maintenance_equipment +from . import maintenance_request diff --git a/maintenance_timesheet/models/hr_timesheet.py b/maintenance_timesheet/models/hr_timesheet.py new file mode 100644 index 000000000..94da25e62 --- /dev/null +++ b/maintenance_timesheet/models/hr_timesheet.py @@ -0,0 +1,47 @@ +# © 2019 Solvos Consultoría Informática () +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from odoo import models, fields, api, _ +from odoo.exceptions import ValidationError + + +class AccountAnalyticLine(models.Model): + _inherit = 'account.analytic.line' + + maintenance_request_id = fields.Many2one( + comodel_name='maintenance.request') + + @api.onchange('maintenance_request_id') + def onchange_maintenance_request_id(self): + if self.maintenance_request_id and not self.project_id: + self.project_id = self.maintenance_request_id.project_id + self.task_id = self.maintenance_request_id.task_id + + @api.model + def create(self, values): + if values.get('maintenance_request_id'): + self._check_request_done(values.get('maintenance_request_id')) + return super().create(values) + + @api.multi + def write(self, values): + current_request = self.maintenance_request_id + new_request_id = values.get('maintenance_request_id', False) + if current_request: + self._check_request_done(current_request.id) + if new_request_id: + self._check_request_done(new_request_id) + return super().write(values) + + def unlink(self): + for timesheet in self.filtered(lambda x: x.maintenance_request_id): + self._check_request_done(timesheet.maintenance_request_id.id) + super().unlink() + + def _check_request_done(self, request_id): + """ + Editing a timesheet related to a finished request is forbidden. + """ + if self.env['maintenance.request'].browse(request_id).stage_id.done: + raise ValidationError(_('Cannot save or delete a timesheet for ' + 'a maintenance request already done')) diff --git a/maintenance_timesheet/models/maintenance_equipment.py b/maintenance_timesheet/models/maintenance_equipment.py new file mode 100644 index 000000000..012a2fd51 --- /dev/null +++ b/maintenance_timesheet/models/maintenance_equipment.py @@ -0,0 +1,13 @@ +# Copyright 2019 Solvos Consultoría Informática () +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from odoo import models + + +class MaintenanceEquipment(models.Model): + _inherit = 'maintenance.equipment' + + def _prepare_project_from_equipment_values(self, values): + data = super()._prepare_project_from_equipment_values(values) + data['allow_timesheets'] = True + return data diff --git a/maintenance_timesheet/models/maintenance_request.py b/maintenance_timesheet/models/maintenance_request.py new file mode 100644 index 000000000..0e7885ce0 --- /dev/null +++ b/maintenance_timesheet/models/maintenance_request.py @@ -0,0 +1,51 @@ +# © 2019 Solvos Consultoría Informática () +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from odoo import models, fields, api + + +class MaintenanceRequest(models.Model): + _inherit = 'maintenance.request' + + timesheet_ids = fields.One2many( + string='Timesheets', + comodel_name='account.analytic.line', + inverse_name='maintenance_request_id') + timesheet_total_hours = fields.Float( + compute='_compute_timesheet_total_hours') + + def _add_followers(self): + """ + Members of maintenance team are included as followers to automatically + grant request visibility and timesheet permissions for this request + """ + super()._add_followers() + for request in self: + partner_ids = \ + request.maintenance_team_id.member_ids.mapped('partner_id').ids + request.message_subscribe(partner_ids=partner_ids) + + @api.depends('timesheet_ids.unit_amount') + def _compute_timesheet_total_hours(self): + for request in self: + request.timesheet_total_hours = \ + sum(request.timesheet_ids.mapped('unit_amount')) + + def action_view_timesheet_ids(self): + """ + Access to the current timesheets for this maintenance request + The view will be restricted to the current request and only HR managers + could create timesheets for every employee + """ + self.ensure_one() + action = self.env.ref( + 'maintenance_timesheet.timesheet_action_from_request').read()[0] + action['domain'] = [('maintenance_request_id', '=', self.id)] + action['context'] = { + 'default_project_id': self.project_id.id, + 'default_task_id': self.task_id.id, + 'default_maintenance_request_id': self.id, + 'readonly_employee_id': not self.env.user.has_group( + 'hr_timesheet.group_timesheet_manager') + } + return action diff --git a/maintenance_timesheet/readme/CONTRIBUTORS.rst b/maintenance_timesheet/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..423455dfe --- /dev/null +++ b/maintenance_timesheet/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* David Alonso diff --git a/maintenance_timesheet/readme/DESCRIPTION.rst b/maintenance_timesheet/readme/DESCRIPTION.rst new file mode 100644 index 000000000..6bfcb8a6c --- /dev/null +++ b/maintenance_timesheet/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module adds timesheets to a request. diff --git a/maintenance_timesheet/security/maintenance_timesheet_security.xml b/maintenance_timesheet/security/maintenance_timesheet_security.xml new file mode 100644 index 000000000..25acd7b55 --- /dev/null +++ b/maintenance_timesheet/security/maintenance_timesheet_security.xml @@ -0,0 +1,26 @@ + + + + + Users are allowed to access timesheets related to a followed request + + [ + '|', + ('maintenance_request_id', '=', False), + '|', + ('maintenance_request_id.message_partner_ids', 'in', [user.partner_id.id]), + ('maintenance_request_id.user_id.id', '=', user.id) + ] + + + + + Managers are allowed to access timesheets related to any request + + + [('maintenance_request_id', '!=', False)] + + + + + diff --git a/maintenance_timesheet/static/description/icon.png b/maintenance_timesheet/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..3a0328b516c4980e8e44cdb63fd945757ddd132d GIT binary patch literal 9455 zcmW++2RxMjAAjx~&dlBk9S+%}OXg)AGE&Cb*&}d0jUxM@u(PQx^-s)697TX`ehR4?GS^qbkof1cslKgkU)h65qZ9Oc=ml_0temigYLJfnz{IDzUf>bGs4N!v3=Z3jMq&A#7%rM5eQ#dc?k~! zVpnB`o+K7|Al`Q_U;eD$B zfJtP*jH`siUq~{KE)`jP2|#TUEFGRryE2`i0**z#*^6~AI|YzIWy$Cu#CSLW3q=GA z6`?GZymC;dCPk~rBS%eCb`5OLr;RUZ;D`}um=H)BfVIq%7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mg4rT8Q_I}h`0d-vYZ^|dOB*Q^S|xqTV*vIg?@fVFSmMpaw0qtTRbx} z({Pg?#{2`sc9)M5N$*N|4;^t$+QP?#mov zGVC@I*lBVrOU-%2y!7%)fAKjpEFsgQc4{amtiHb95KQEwvf<(3T<9-Zm$xIew#P22 zc2Ix|App^>v6(3L_MCU0d3W##AB0M~3D00EWoKZqsJYT(#@w$Y_H7G22M~ApVFTRHMI_3be)Lkn#0F*V8Pq zc}`Cjy$bE;FJ6H7p=0y#R>`}-m4(0F>%@P|?7fx{=R^uFdISRnZ2W_xQhD{YuR3t< z{6yxu=4~JkeA;|(J6_nv#>Nvs&FuLA&PW^he@t(UwFFE8)|a!R{`E`K`i^ZnyE4$k z;(749Ix|oi$c3QbEJ3b~D_kQsPz~fIUKym($a_7dJ?o+40*OLl^{=&oq$<#Q(yyrp z{J-FAniyAw9tPbe&IhQ|a`DqFTVQGQ&Gq3!C2==4x{6EJwiPZ8zub-iXoUtkJiG{} zPaR&}_fn8_z~(=;5lD-aPWD3z8PZS@AaUiomF!G8I}Mf>e~0g#BelA-5#`cj;O5>N Xviia!U7SGha1wx#SCgwmn*{w2TRX*I literal 0 HcmV?d00001 diff --git a/maintenance_timesheet/static/description/index.html b/maintenance_timesheet/static/description/index.html new file mode 100644 index 000000000..540919a08 --- /dev/null +++ b/maintenance_timesheet/static/description/index.html @@ -0,0 +1,419 @@ + + + + + + +Maintenance Timesheets + + + +
+

Maintenance Timesheets

+ + +

Beta License: AGPL-3 OCA/maintenance Translate me on Weblate Try me on Runbot

+

This module adds timesheets to a request.

+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Solvos
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/maintenance project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/maintenance_timesheet/tests/__init__.py b/maintenance_timesheet/tests/__init__.py new file mode 100644 index 000000000..2c3cdf5b4 --- /dev/null +++ b/maintenance_timesheet/tests/__init__.py @@ -0,0 +1 @@ +from . import test_maintenance_timesheet diff --git a/maintenance_timesheet/tests/test_maintenance_timesheet.py b/maintenance_timesheet/tests/test_maintenance_timesheet.py new file mode 100644 index 000000000..f6c57341e --- /dev/null +++ b/maintenance_timesheet/tests/test_maintenance_timesheet.py @@ -0,0 +1,71 @@ +# Copyright 2019 Solvos Consultoría Informática () +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +import odoo.tests.common as test_common +from odoo import fields +from odoo.exceptions import ValidationError + + +class TestMaintenanceTimesheet(test_common.TransactionCase): + + def setUp(self): + super().setUp() + + self.stage_undone = self.env.ref('maintenance.stage_0') + self.stage_done = self.env.ref('maintenance.stage_4') + + self.request_demo1 = self.env.ref('maintenance_timesheet.request_1') + self.request2 = self.env['maintenance.request'].create({ + 'name': 'Corrective #2 for Generic Monitor', + 'equipment_id': self.env.ref('maintenance_project.equipment_1').id, + 'user_id': self.env.ref('base.user_admin').id, + 'schedule_date': fields.Date.today(), + 'stage_id': self.stage_undone.id, + 'maintenance_type': 'corrective'}) + self.timesheet21_data = { + 'name': 'Some tasks done', + 'project_id': self.request2.project_id.id, + 'user_id': self.env.ref('base.user_admin').id, + 'date': fields.Date.today(), + 'unit_amount': 1.5} + self.request2.timesheet_ids = [(0, 0, self.timesheet21_data)] + + def test_request_timesheets(self): + self.assertEqual(self.request_demo1.timesheet_total_hours, 2) + self.assertEqual(self.request2.timesheet_total_hours, + self.timesheet21_data['unit_amount']) + + def test_onchange_maintenance_request_id(self): + ts1 = self.env['account.analytic.line'].new({ + 'date': fields.Date.today(), + 'name': 'Timesheet without initial equipment', + 'user_id': self.env.ref('base.user_admin').id}) + self.assertFalse(ts1.project_id) + ts1.maintenance_request_id = self.request2 + ts1.onchange_maintenance_request_id() + self.assertEqual(ts1.project_id, self.request2.project_id) + + def test_check_request_done(self): + self.request2.stage_id = self.stage_done + with self.assertRaises(ValidationError): + self.request2.timesheet_ids = [(0, 0, { + 'name': 'Attempt to create a task for a done request', + 'project_id': self.request2.project_id.id, + 'user_id': self.env.ref('base.user_admin').id, + 'date': fields.Date.today(), + 'unit_amount': 2})] + with self.assertRaises(ValidationError): + # Attempt to modify a timesheet related a done request + for timesheet in self.request2.timesheet_ids: + timesheet.unit_amount += 1 + with self.assertRaises(ValidationError): + # Attempt to delete a timesheet related a done request + self.request2.timesheet_ids.unlink() + + def test_action_view_timesheet_ids(self): + act1 = self.request2.action_view_timesheet_ids() + self.assertEqual(act1['domain'][0][2], self.request2.id) + self.assertEqual(act1['context']['default_project_id'], + self.request2.project_id.id) + self.assertFalse(act1['context']['default_task_id']) + self.assertFalse(act1['context']['readonly_employee_id']) diff --git a/maintenance_timesheet/views/hr_timesheet_views.xml b/maintenance_timesheet/views/hr_timesheet_views.xml new file mode 100644 index 000000000..6794914d4 --- /dev/null +++ b/maintenance_timesheet/views/hr_timesheet_views.xml @@ -0,0 +1,49 @@ + + + + + account.analytic.line + + + + + + + + + + + + + account.analytic.line + + + + + + + + + + account.analytic.line + + + + context.get('readonly_employee_id', False) + + + + + + account.analytic.line + + + + + + + + + diff --git a/maintenance_timesheet/views/maintenance_request_views.xml b/maintenance_timesheet/views/maintenance_request_views.xml new file mode 100644 index 000000000..17e649918 --- /dev/null +++ b/maintenance_timesheet/views/maintenance_request_views.xml @@ -0,0 +1,75 @@ + + + + + Timesheets + account.analytic.line + + [('project_id', '!=', False), ('maintenance_request_id', '!=', False)] + + + + + tree + + + + + + + form + + + + + + + maintenance.request + + + + + + + + + + maintenance.request + + + + + + + +
+ + Hours +
+
+
+
+
+ + + maintenance.request + + + + +
+ +
+
+ + + +
+
+ +
From 7cd12ed9f4e5d4385b8fe3b7e3f2f20cfa0ae7c2 Mon Sep 17 00:00:00 2001 From: "David Alonso (Solvos)" Date: Tue, 3 Mar 2020 17:53:07 +0100 Subject: [PATCH 02/16] [IMP] maintenance_timesheet: black, isort --- maintenance_timesheet/__manifest__.py | 11 +-- maintenance_timesheet/models/hr_timesheet.py | 25 +++--- .../models/maintenance_equipment.py | 4 +- .../models/maintenance_request.py | 44 +++++----- .../tests/test_maintenance_timesheet.py | 81 +++++++++++-------- 5 files changed, 91 insertions(+), 74 deletions(-) diff --git a/maintenance_timesheet/__manifest__.py b/maintenance_timesheet/__manifest__.py index 8aa1247e6..d2ad46c9a 100644 --- a/maintenance_timesheet/__manifest__.py +++ b/maintenance_timesheet/__manifest__.py @@ -8,17 +8,12 @@ "version": "12.0.1.0.1", "category": "Human Resources", "website": "https://github.com/OCA/maintenance", - "depends": [ - "maintenance_project", - "hr_timesheet", - ], + "depends": ["maintenance_project", "hr_timesheet"], "data": [ "security/maintenance_timesheet_security.xml", "views/hr_timesheet_views.xml", "views/maintenance_request_views.xml", ], - "demo": [ - "data/demo_maintenance_timesheet.xml", - ], - 'installable': True, + "demo": ["data/demo_maintenance_timesheet.xml"], + "installable": True, } diff --git a/maintenance_timesheet/models/hr_timesheet.py b/maintenance_timesheet/models/hr_timesheet.py index 94da25e62..cfe803522 100644 --- a/maintenance_timesheet/models/hr_timesheet.py +++ b/maintenance_timesheet/models/hr_timesheet.py @@ -1,17 +1,16 @@ # © 2019 Solvos Consultoría Informática () # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html -from odoo import models, fields, api, _ +from odoo import _, api, fields, models from odoo.exceptions import ValidationError class AccountAnalyticLine(models.Model): - _inherit = 'account.analytic.line' + _inherit = "account.analytic.line" - maintenance_request_id = fields.Many2one( - comodel_name='maintenance.request') + maintenance_request_id = fields.Many2one(comodel_name="maintenance.request") - @api.onchange('maintenance_request_id') + @api.onchange("maintenance_request_id") def onchange_maintenance_request_id(self): if self.maintenance_request_id and not self.project_id: self.project_id = self.maintenance_request_id.project_id @@ -19,14 +18,14 @@ def onchange_maintenance_request_id(self): @api.model def create(self, values): - if values.get('maintenance_request_id'): - self._check_request_done(values.get('maintenance_request_id')) + if values.get("maintenance_request_id"): + self._check_request_done(values.get("maintenance_request_id")) return super().create(values) @api.multi def write(self, values): current_request = self.maintenance_request_id - new_request_id = values.get('maintenance_request_id', False) + new_request_id = values.get("maintenance_request_id", False) if current_request: self._check_request_done(current_request.id) if new_request_id: @@ -42,6 +41,10 @@ def _check_request_done(self, request_id): """ Editing a timesheet related to a finished request is forbidden. """ - if self.env['maintenance.request'].browse(request_id).stage_id.done: - raise ValidationError(_('Cannot save or delete a timesheet for ' - 'a maintenance request already done')) + if self.env["maintenance.request"].browse(request_id).stage_id.done: + raise ValidationError( + _( + "Cannot save or delete a timesheet for " + "a maintenance request already done" + ) + ) diff --git a/maintenance_timesheet/models/maintenance_equipment.py b/maintenance_timesheet/models/maintenance_equipment.py index 012a2fd51..a5753ba03 100644 --- a/maintenance_timesheet/models/maintenance_equipment.py +++ b/maintenance_timesheet/models/maintenance_equipment.py @@ -5,9 +5,9 @@ class MaintenanceEquipment(models.Model): - _inherit = 'maintenance.equipment' + _inherit = "maintenance.equipment" def _prepare_project_from_equipment_values(self, values): data = super()._prepare_project_from_equipment_values(values) - data['allow_timesheets'] = True + data["allow_timesheets"] = True return data diff --git a/maintenance_timesheet/models/maintenance_request.py b/maintenance_timesheet/models/maintenance_request.py index 0e7885ce0..b7f851cee 100644 --- a/maintenance_timesheet/models/maintenance_request.py +++ b/maintenance_timesheet/models/maintenance_request.py @@ -1,18 +1,18 @@ # © 2019 Solvos Consultoría Informática () # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html -from odoo import models, fields, api +from odoo import api, fields, models class MaintenanceRequest(models.Model): - _inherit = 'maintenance.request' + _inherit = "maintenance.request" timesheet_ids = fields.One2many( - string='Timesheets', - comodel_name='account.analytic.line', - inverse_name='maintenance_request_id') - timesheet_total_hours = fields.Float( - compute='_compute_timesheet_total_hours') + string="Timesheets", + comodel_name="account.analytic.line", + inverse_name="maintenance_request_id", + ) + timesheet_total_hours = fields.Float(compute="_compute_timesheet_total_hours") def _add_followers(self): """ @@ -21,15 +21,17 @@ def _add_followers(self): """ super()._add_followers() for request in self: - partner_ids = \ - request.maintenance_team_id.member_ids.mapped('partner_id').ids + partner_ids = request.maintenance_team_id.member_ids.mapped( + "partner_id" + ).ids request.message_subscribe(partner_ids=partner_ids) - @api.depends('timesheet_ids.unit_amount') + @api.depends("timesheet_ids.unit_amount") def _compute_timesheet_total_hours(self): for request in self: - request.timesheet_total_hours = \ - sum(request.timesheet_ids.mapped('unit_amount')) + request.timesheet_total_hours = sum( + request.timesheet_ids.mapped("unit_amount") + ) def action_view_timesheet_ids(self): """ @@ -39,13 +41,15 @@ def action_view_timesheet_ids(self): """ self.ensure_one() action = self.env.ref( - 'maintenance_timesheet.timesheet_action_from_request').read()[0] - action['domain'] = [('maintenance_request_id', '=', self.id)] - action['context'] = { - 'default_project_id': self.project_id.id, - 'default_task_id': self.task_id.id, - 'default_maintenance_request_id': self.id, - 'readonly_employee_id': not self.env.user.has_group( - 'hr_timesheet.group_timesheet_manager') + "maintenance_timesheet.timesheet_action_from_request" + ).read()[0] + action["domain"] = [("maintenance_request_id", "=", self.id)] + action["context"] = { + "default_project_id": self.project_id.id, + "default_task_id": self.task_id.id, + "default_maintenance_request_id": self.id, + "readonly_employee_id": not self.env.user.has_group( + "hr_timesheet.group_timesheet_manager" + ), } return action diff --git a/maintenance_timesheet/tests/test_maintenance_timesheet.py b/maintenance_timesheet/tests/test_maintenance_timesheet.py index f6c57341e..bd44491b6 100644 --- a/maintenance_timesheet/tests/test_maintenance_timesheet.py +++ b/maintenance_timesheet/tests/test_maintenance_timesheet.py @@ -7,39 +7,46 @@ class TestMaintenanceTimesheet(test_common.TransactionCase): - def setUp(self): super().setUp() - self.stage_undone = self.env.ref('maintenance.stage_0') - self.stage_done = self.env.ref('maintenance.stage_4') + self.stage_undone = self.env.ref("maintenance.stage_0") + self.stage_done = self.env.ref("maintenance.stage_4") - self.request_demo1 = self.env.ref('maintenance_timesheet.request_1') - self.request2 = self.env['maintenance.request'].create({ - 'name': 'Corrective #2 for Generic Monitor', - 'equipment_id': self.env.ref('maintenance_project.equipment_1').id, - 'user_id': self.env.ref('base.user_admin').id, - 'schedule_date': fields.Date.today(), - 'stage_id': self.stage_undone.id, - 'maintenance_type': 'corrective'}) + self.request_demo1 = self.env.ref("maintenance_timesheet.request_1") + self.request2 = self.env["maintenance.request"].create( + { + "name": "Corrective #2 for Generic Monitor", + "equipment_id": self.env.ref("maintenance_project.equipment_1").id, + "user_id": self.env.ref("base.user_admin").id, + "schedule_date": fields.Date.today(), + "stage_id": self.stage_undone.id, + "maintenance_type": "corrective", + } + ) self.timesheet21_data = { - 'name': 'Some tasks done', - 'project_id': self.request2.project_id.id, - 'user_id': self.env.ref('base.user_admin').id, - 'date': fields.Date.today(), - 'unit_amount': 1.5} + "name": "Some tasks done", + "project_id": self.request2.project_id.id, + "user_id": self.env.ref("base.user_admin").id, + "date": fields.Date.today(), + "unit_amount": 1.5, + } self.request2.timesheet_ids = [(0, 0, self.timesheet21_data)] def test_request_timesheets(self): self.assertEqual(self.request_demo1.timesheet_total_hours, 2) - self.assertEqual(self.request2.timesheet_total_hours, - self.timesheet21_data['unit_amount']) + self.assertEqual( + self.request2.timesheet_total_hours, self.timesheet21_data["unit_amount"] + ) def test_onchange_maintenance_request_id(self): - ts1 = self.env['account.analytic.line'].new({ - 'date': fields.Date.today(), - 'name': 'Timesheet without initial equipment', - 'user_id': self.env.ref('base.user_admin').id}) + ts1 = self.env["account.analytic.line"].new( + { + "date": fields.Date.today(), + "name": "Timesheet without initial equipment", + "user_id": self.env.ref("base.user_admin").id, + } + ) self.assertFalse(ts1.project_id) ts1.maintenance_request_id = self.request2 ts1.onchange_maintenance_request_id() @@ -48,12 +55,19 @@ def test_onchange_maintenance_request_id(self): def test_check_request_done(self): self.request2.stage_id = self.stage_done with self.assertRaises(ValidationError): - self.request2.timesheet_ids = [(0, 0, { - 'name': 'Attempt to create a task for a done request', - 'project_id': self.request2.project_id.id, - 'user_id': self.env.ref('base.user_admin').id, - 'date': fields.Date.today(), - 'unit_amount': 2})] + self.request2.timesheet_ids = [ + ( + 0, + 0, + { + "name": "Attempt to create a task for a done request", + "project_id": self.request2.project_id.id, + "user_id": self.env.ref("base.user_admin").id, + "date": fields.Date.today(), + "unit_amount": 2, + }, + ) + ] with self.assertRaises(ValidationError): # Attempt to modify a timesheet related a done request for timesheet in self.request2.timesheet_ids: @@ -64,8 +78,9 @@ def test_check_request_done(self): def test_action_view_timesheet_ids(self): act1 = self.request2.action_view_timesheet_ids() - self.assertEqual(act1['domain'][0][2], self.request2.id) - self.assertEqual(act1['context']['default_project_id'], - self.request2.project_id.id) - self.assertFalse(act1['context']['default_task_id']) - self.assertFalse(act1['context']['readonly_employee_id']) + self.assertEqual(act1["domain"][0][2], self.request2.id) + self.assertEqual( + act1["context"]["default_project_id"], self.request2.project_id.id + ) + self.assertFalse(act1["context"]["default_task_id"]) + self.assertFalse(act1["context"]["readonly_employee_id"]) From c6a65903f0393697dc63b6a0579482ce0d37d67d Mon Sep 17 00:00:00 2001 From: "David Alonso (Solvos)" Date: Tue, 3 Mar 2020 18:23:04 +0100 Subject: [PATCH 03/16] [MIG] maintenance_timesheet: Migration to 13.0 [UPD] Update maintenance_timesheet.pot pre-commit update Update translation files Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: maintenance-13.0/maintenance-13.0-maintenance_timesheet Translate-URL: https://translation.odoo-community.org/projects/maintenance-13-0/maintenance-13-0-maintenance_timesheet/ --- maintenance_timesheet/README.rst | 10 +-- maintenance_timesheet/__manifest__.py | 4 +- .../data/demo_maintenance_timesheet.xml | 58 ++++++------ maintenance_timesheet/i18n/es.po | 2 +- .../i18n/maintenance_timesheet.pot | 12 +-- maintenance_timesheet/models/hr_timesheet.py | 1 - .../maintenance_timesheet_security.xml | 24 +++-- .../static/description/index.html | 6 +- .../views/hr_timesheet_views.xml | 27 +++--- .../views/maintenance_request_views.xml | 88 +++++++++++-------- 10 files changed, 134 insertions(+), 98 deletions(-) diff --git a/maintenance_timesheet/README.rst b/maintenance_timesheet/README.rst index fb201201c..4acff1223 100644 --- a/maintenance_timesheet/README.rst +++ b/maintenance_timesheet/README.rst @@ -14,13 +14,13 @@ Maintenance Timesheets :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fmaintenance-lightgray.png?logo=github - :target: https://github.com/OCA/maintenance/tree/12.0/maintenance_timesheet + :target: https://github.com/OCA/maintenance/tree/13.0/maintenance_timesheet :alt: OCA/maintenance .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/maintenance-12-0/maintenance-12-0-maintenance_timesheet + :target: https://translation.odoo-community.org/projects/maintenance-13-0/maintenance-13-0-maintenance_timesheet :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png - :target: https://runbot.odoo-community.org/runbot/240/12.0 + :target: https://runbot.odoo-community.org/runbot/240/13.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| @@ -38,7 +38,7 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -68,6 +68,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -This module is part of the `OCA/maintenance `_ project on GitHub. +This module is part of the `OCA/maintenance `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/maintenance_timesheet/__manifest__.py b/maintenance_timesheet/__manifest__.py index d2ad46c9a..e78b88a83 100644 --- a/maintenance_timesheet/__manifest__.py +++ b/maintenance_timesheet/__manifest__.py @@ -5,10 +5,10 @@ "summary": "Adds timesheets to maintenance requests", "author": "Odoo Community Association (OCA), Solvos", "license": "AGPL-3", - "version": "12.0.1.0.1", + "version": "13.0.1.0.0", "category": "Human Resources", "website": "https://github.com/OCA/maintenance", - "depends": ["maintenance_project", "hr_timesheet"], + "depends": ["base_maintenance", "maintenance_project", "hr_timesheet"], "data": [ "security/maintenance_timesheet_security.xml", "views/hr_timesheet_views.xml", diff --git a/maintenance_timesheet/data/demo_maintenance_timesheet.xml b/maintenance_timesheet/data/demo_maintenance_timesheet.xml index 8c49ea205..9ce6dd8d3 100644 --- a/maintenance_timesheet/data/demo_maintenance_timesheet.xml +++ b/maintenance_timesheet/data/demo_maintenance_timesheet.xml @@ -1,44 +1,50 @@ - - + - Corrective #1 for Generic Monitor - - - - - + + + + + corrective - - + Request tasks done - - - - - + + + + + - - - + + - - + Touchpad repaired - - - - - + + + + + - diff --git a/maintenance_timesheet/i18n/es.po b/maintenance_timesheet/i18n/es.po index 63c0c413c..2456d21c1 100644 --- a/maintenance_timesheet/i18n/es.po +++ b/maintenance_timesheet/i18n/es.po @@ -33,7 +33,7 @@ msgid "Analytic Line" msgstr "Cuenta analítica" #. module: maintenance_timesheet -#: code:addons/maintenance_timesheet/models/hr_timesheet.py:46 +#: code:addons/maintenance_timesheet/models/hr_timesheet.py:0 #, python-format msgid "" "Cannot save or delete a timesheet for a maintenance request already done" diff --git a/maintenance_timesheet/i18n/maintenance_timesheet.pot b/maintenance_timesheet/i18n/maintenance_timesheet.pot index dd1ecd266..7d0f20fa5 100644 --- a/maintenance_timesheet/i18n/maintenance_timesheet.pot +++ b/maintenance_timesheet/i18n/maintenance_timesheet.pot @@ -1,12 +1,12 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: -# * maintenance_timesheet +# * maintenance_timesheet # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 12.0\n" +"Project-Id-Version: Odoo Server 13.0\n" "Report-Msgid-Bugs-To: \n" -"Last-Translator: <>\n" +"Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -29,9 +29,10 @@ msgid "Analytic Line" msgstr "" #. module: maintenance_timesheet -#: code:addons/maintenance_timesheet/models/hr_timesheet.py:46 +#: code:addons/maintenance_timesheet/models/hr_timesheet.py:0 #, python-format -msgid "Cannot save or delete a timesheet for a maintenance request already done" +msgid "" +"Cannot save or delete a timesheet for a maintenance request already done" msgstr "" #. module: maintenance_timesheet @@ -60,4 +61,3 @@ msgstr "" #: model:ir.model.fields,field_description:maintenance_timesheet.field_maintenance_request__timesheet_ids msgid "Timesheets" msgstr "" - diff --git a/maintenance_timesheet/models/hr_timesheet.py b/maintenance_timesheet/models/hr_timesheet.py index cfe803522..e82aa3787 100644 --- a/maintenance_timesheet/models/hr_timesheet.py +++ b/maintenance_timesheet/models/hr_timesheet.py @@ -22,7 +22,6 @@ def create(self, values): self._check_request_done(values.get("maintenance_request_id")) return super().create(values) - @api.multi def write(self, values): current_request = self.maintenance_request_id new_request_id = values.get("maintenance_request_id", False) diff --git a/maintenance_timesheet/security/maintenance_timesheet_security.xml b/maintenance_timesheet/security/maintenance_timesheet_security.xml index 25acd7b55..654d0e769 100644 --- a/maintenance_timesheet/security/maintenance_timesheet_security.xml +++ b/maintenance_timesheet/security/maintenance_timesheet_security.xml @@ -1,9 +1,11 @@ - + - Users are allowed to access timesheets related to a followed request - + Users are allowed to access timesheets related to a followed request + [ '|', ('maintenance_request_id', '=', False), @@ -12,15 +14,23 @@ ('maintenance_request_id.user_id.id', '=', user.id) ] - + - Managers are allowed to access timesheets related to any request - + Managers are allowed to access timesheets related to any request + [('maintenance_request_id', '!=', False)] - + diff --git a/maintenance_timesheet/static/description/index.html b/maintenance_timesheet/static/description/index.html index 540919a08..41762a30a 100644 --- a/maintenance_timesheet/static/description/index.html +++ b/maintenance_timesheet/static/description/index.html @@ -367,7 +367,7 @@

Maintenance Timesheets

!! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: AGPL-3 OCA/maintenance Translate me on Weblate Try me on Runbot

+

Beta License: AGPL-3 OCA/maintenance Translate me on Weblate Try me on Runbot

This module adds timesheets to a request.

Table of contents

@@ -386,7 +386,7 @@

Bug Tracker

Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed -feedback.

+feedback.

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

@@ -410,7 +410,7 @@

Maintainers

OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

-

This module is part of the OCA/maintenance project on GitHub.

+

This module is part of the OCA/maintenance project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

diff --git a/maintenance_timesheet/views/hr_timesheet_views.xml b/maintenance_timesheet/views/hr_timesheet_views.xml index 6794914d4..9f69490e7 100644 --- a/maintenance_timesheet/views/hr_timesheet_views.xml +++ b/maintenance_timesheet/views/hr_timesheet_views.xml @@ -1,41 +1,45 @@ - + - account.analytic.line - + - + - account.analytic.line - + - account.analytic.line - context.get('readonly_employee_id', False) + context.get('readonly_employee_id', False) - account.analytic.line @@ -45,5 +49,4 @@ - diff --git a/maintenance_timesheet/views/maintenance_request_views.xml b/maintenance_timesheet/views/maintenance_request_views.xml index 17e649918..2cf38393f 100644 --- a/maintenance_timesheet/views/maintenance_request_views.xml +++ b/maintenance_timesheet/views/maintenance_request_views.xml @@ -1,75 +1,93 @@ - + - Timesheets account.analytic.line - - [('project_id', '!=', False), ('maintenance_request_id', '!=', False)] + + [('project_id', '!=', False), ('maintenance_request_id', '!=', False)] - - - + + tree - - + + - - - + + form - - + + - maintenance.request - + - maintenance.request - + - +
- + + + + Hours
- maintenance.request - - -
- -
-
- - + +
-
From d18dbacee6cdf3a45ca807aa71c318a0edc08495 Mon Sep 17 00:00:00 2001 From: David Alonso Date: Thu, 17 Dec 2020 13:17:52 +0100 Subject: [PATCH 04/16] [IMP] maintenance_timesheet: add report support for requests [UPD] Update maintenance_timesheet.pot [UPD] README.rst maintenance_timesheet 13.0.1.1.0 Update translation files Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: maintenance-13.0/maintenance-13.0-maintenance_timesheet Translate-URL: https://translation.odoo-community.org/projects/maintenance-13-0/maintenance-13-0-maintenance_timesheet/ --- maintenance_timesheet/README.rst | 1 + maintenance_timesheet/__manifest__.py | 5 +- maintenance_timesheet/i18n/es.po | 45 ++++++++ .../i18n/maintenance_timesheet.pot | 45 ++++++++ maintenance_timesheet/readme/CONTRIBUTORS.rst | 1 + .../report/maintenance_request_report.xml | 103 ++++++++++++++++++ .../static/description/index.html | 1 + 7 files changed, 199 insertions(+), 2 deletions(-) create mode 100644 maintenance_timesheet/report/maintenance_request_report.xml diff --git a/maintenance_timesheet/README.rst b/maintenance_timesheet/README.rst index 4acff1223..70faa5e34 100644 --- a/maintenance_timesheet/README.rst +++ b/maintenance_timesheet/README.rst @@ -54,6 +54,7 @@ Contributors ~~~~~~~~~~~~ * David Alonso +* Luisa Miguéns Maintainers ~~~~~~~~~~~ diff --git a/maintenance_timesheet/__manifest__.py b/maintenance_timesheet/__manifest__.py index e78b88a83..291c422ed 100644 --- a/maintenance_timesheet/__manifest__.py +++ b/maintenance_timesheet/__manifest__.py @@ -1,11 +1,11 @@ -# © 2019 Solvos Consultoría Informática () +# © 2020 Solvos Consultoría Informática () # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html { "name": "Maintenance Timesheets", "summary": "Adds timesheets to maintenance requests", "author": "Odoo Community Association (OCA), Solvos", "license": "AGPL-3", - "version": "13.0.1.0.0", + "version": "13.0.1.1.0", "category": "Human Resources", "website": "https://github.com/OCA/maintenance", "depends": ["base_maintenance", "maintenance_project", "hr_timesheet"], @@ -13,6 +13,7 @@ "security/maintenance_timesheet_security.xml", "views/hr_timesheet_views.xml", "views/maintenance_request_views.xml", + "report/maintenance_request_report.xml", ], "demo": ["data/demo_maintenance_timesheet.xml"], "installable": True, diff --git a/maintenance_timesheet/i18n/es.po b/maintenance_timesheet/i18n/es.po index 2456d21c1..48b8bb2e6 100644 --- a/maintenance_timesheet/i18n/es.po +++ b/maintenance_timesheet/i18n/es.po @@ -27,6 +27,21 @@ msgstr "horas" msgid "Hours" msgstr "horas" +#. module: maintenance_timesheet +#: model_terms:ir.ui.view,arch_db:maintenance_timesheet.report_maintenance_request_document +msgid "Timesheet Entries" +msgstr "" + +#. module: maintenance_timesheet +#: model_terms:ir.ui.view,arch_db:maintenance_timesheet.report_maintenance_request_document +msgid "Timesheet Total Hours:" +msgstr "" + +#. module: maintenance_timesheet +#: model_terms:ir.ui.view,arch_db:maintenance_timesheet.report_maintenance_request_document +msgid "Total" +msgstr "" + #. module: maintenance_timesheet #: model:ir.model,name:maintenance_timesheet.model_account_analytic_line msgid "Analytic Line" @@ -41,6 +56,16 @@ msgstr "" "No se puede editar o borrar un parte de trabajo de una petición de " "mantenimiento ya finalizada" +#. module: maintenance_timesheet +#: model_terms:ir.ui.view,arch_db:maintenance_timesheet.report_maintenance_request_document +msgid "Date" +msgstr "" + +#. module: maintenance_timesheet +#: model_terms:ir.ui.view,arch_db:maintenance_timesheet.report_maintenance_request_document +msgid "Description" +msgstr "" + #. module: maintenance_timesheet #: model:ir.model,name:maintenance_timesheet.model_maintenance_equipment msgid "Maintenance Equipment" @@ -52,11 +77,31 @@ msgstr "Equipo" msgid "Maintenance Request" msgstr "Petición de mantenimiento" +#. module: maintenance_timesheet +#: model_terms:ir.ui.view,arch_db:maintenance_timesheet.report_maintenance_request_document +msgid "Project -" +msgstr "" + #. module: maintenance_timesheet #: model_terms:ir.ui.view,arch_db:maintenance_timesheet.hr_timesheet_line_search msgid "Request" msgstr "Petición" +#. module: maintenance_timesheet +#: model_terms:ir.ui.view,arch_db:maintenance_timesheet.report_maintenance_request_document +msgid "Responsible" +msgstr "" + +#. module: maintenance_timesheet +#: model_terms:ir.ui.view,arch_db:maintenance_timesheet.report_maintenance_request_document +msgid "Task" +msgstr "" + +#. module: maintenance_timesheet +#: model_terms:ir.ui.view,arch_db:maintenance_timesheet.report_maintenance_request_document +msgid "Time" +msgstr "" + #. module: maintenance_timesheet #: model:ir.model.fields,field_description:maintenance_timesheet.field_maintenance_request__timesheet_total_hours msgid "Timesheet Total Hours" diff --git a/maintenance_timesheet/i18n/maintenance_timesheet.pot b/maintenance_timesheet/i18n/maintenance_timesheet.pot index 7d0f20fa5..e659d6d63 100644 --- a/maintenance_timesheet/i18n/maintenance_timesheet.pot +++ b/maintenance_timesheet/i18n/maintenance_timesheet.pot @@ -23,6 +23,21 @@ msgstr "" msgid "Hours" msgstr "" +#. module: maintenance_timesheet +#: model_terms:ir.ui.view,arch_db:maintenance_timesheet.report_maintenance_request_document +msgid "Timesheet Entries" +msgstr "" + +#. module: maintenance_timesheet +#: model_terms:ir.ui.view,arch_db:maintenance_timesheet.report_maintenance_request_document +msgid "Timesheet Total Hours:" +msgstr "" + +#. module: maintenance_timesheet +#: model_terms:ir.ui.view,arch_db:maintenance_timesheet.report_maintenance_request_document +msgid "Total" +msgstr "" + #. module: maintenance_timesheet #: model:ir.model,name:maintenance_timesheet.model_account_analytic_line msgid "Analytic Line" @@ -35,6 +50,16 @@ msgid "" "Cannot save or delete a timesheet for a maintenance request already done" msgstr "" +#. module: maintenance_timesheet +#: model_terms:ir.ui.view,arch_db:maintenance_timesheet.report_maintenance_request_document +msgid "Date" +msgstr "" + +#. module: maintenance_timesheet +#: model_terms:ir.ui.view,arch_db:maintenance_timesheet.report_maintenance_request_document +msgid "Description" +msgstr "" + #. module: maintenance_timesheet #: model:ir.model,name:maintenance_timesheet.model_maintenance_equipment msgid "Maintenance Equipment" @@ -46,11 +71,31 @@ msgstr "" msgid "Maintenance Request" msgstr "" +#. module: maintenance_timesheet +#: model_terms:ir.ui.view,arch_db:maintenance_timesheet.report_maintenance_request_document +msgid "Project -" +msgstr "" + #. module: maintenance_timesheet #: model_terms:ir.ui.view,arch_db:maintenance_timesheet.hr_timesheet_line_search msgid "Request" msgstr "" +#. module: maintenance_timesheet +#: model_terms:ir.ui.view,arch_db:maintenance_timesheet.report_maintenance_request_document +msgid "Responsible" +msgstr "" + +#. module: maintenance_timesheet +#: model_terms:ir.ui.view,arch_db:maintenance_timesheet.report_maintenance_request_document +msgid "Task" +msgstr "" + +#. module: maintenance_timesheet +#: model_terms:ir.ui.view,arch_db:maintenance_timesheet.report_maintenance_request_document +msgid "Time" +msgstr "" + #. module: maintenance_timesheet #: model:ir.model.fields,field_description:maintenance_timesheet.field_maintenance_request__timesheet_total_hours msgid "Timesheet Total Hours" diff --git a/maintenance_timesheet/readme/CONTRIBUTORS.rst b/maintenance_timesheet/readme/CONTRIBUTORS.rst index 423455dfe..b4e59565a 100644 --- a/maintenance_timesheet/readme/CONTRIBUTORS.rst +++ b/maintenance_timesheet/readme/CONTRIBUTORS.rst @@ -1 +1,2 @@ * David Alonso +* Luisa Miguéns diff --git a/maintenance_timesheet/report/maintenance_request_report.xml b/maintenance_timesheet/report/maintenance_request_report.xml new file mode 100644 index 000000000..6e40ca7df --- /dev/null +++ b/maintenance_timesheet/report/maintenance_request_report.xml @@ -0,0 +1,103 @@ + + + + + + diff --git a/maintenance_timesheet/static/description/index.html b/maintenance_timesheet/static/description/index.html index 41762a30a..7c647f78b 100644 --- a/maintenance_timesheet/static/description/index.html +++ b/maintenance_timesheet/static/description/index.html @@ -401,6 +401,7 @@

Authors

Contributors

From 4cd363b0860dcff04ed4759c90ccc04a8ff050bd Mon Sep 17 00:00:00 2001 From: David Alonso Date: Tue, 19 Jan 2021 09:46:48 +0100 Subject: [PATCH 05/16] [MIG] maintenance_timesheet: Migration to 14.0 [UPD] Update maintenance_timesheet.pot [UPD] README.rst --- maintenance_timesheet/README.rst | 10 ++++---- maintenance_timesheet/__manifest__.py | 2 +- .../i18n/maintenance_timesheet.pot | 23 ++++++++++++++++++- .../models/maintenance_request.py | 4 ++-- .../static/description/index.html | 6 ++--- .../tests/test_maintenance_timesheet.py | 21 +++++++++++++++++ 6 files changed, 54 insertions(+), 12 deletions(-) diff --git a/maintenance_timesheet/README.rst b/maintenance_timesheet/README.rst index 70faa5e34..34ca1d9e5 100644 --- a/maintenance_timesheet/README.rst +++ b/maintenance_timesheet/README.rst @@ -14,13 +14,13 @@ Maintenance Timesheets :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fmaintenance-lightgray.png?logo=github - :target: https://github.com/OCA/maintenance/tree/13.0/maintenance_timesheet + :target: https://github.com/OCA/maintenance/tree/14.0/maintenance_timesheet :alt: OCA/maintenance .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/maintenance-13-0/maintenance-13-0-maintenance_timesheet + :target: https://translation.odoo-community.org/projects/maintenance-14-0/maintenance-14-0-maintenance_timesheet :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png - :target: https://runbot.odoo-community.org/runbot/240/13.0 + :target: https://runbot.odoo-community.org/runbot/240/14.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| @@ -38,7 +38,7 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -69,6 +69,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -This module is part of the `OCA/maintenance `_ project on GitHub. +This module is part of the `OCA/maintenance `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/maintenance_timesheet/__manifest__.py b/maintenance_timesheet/__manifest__.py index 291c422ed..d7a796bb4 100644 --- a/maintenance_timesheet/__manifest__.py +++ b/maintenance_timesheet/__manifest__.py @@ -5,7 +5,7 @@ "summary": "Adds timesheets to maintenance requests", "author": "Odoo Community Association (OCA), Solvos", "license": "AGPL-3", - "version": "13.0.1.1.0", + "version": "14.0.1.0.0", "category": "Human Resources", "website": "https://github.com/OCA/maintenance", "depends": ["base_maintenance", "maintenance_project", "hr_timesheet"], diff --git a/maintenance_timesheet/i18n/maintenance_timesheet.pot b/maintenance_timesheet/i18n/maintenance_timesheet.pot index e659d6d63..1e20aca9a 100644 --- a/maintenance_timesheet/i18n/maintenance_timesheet.pot +++ b/maintenance_timesheet/i18n/maintenance_timesheet.pot @@ -4,7 +4,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 13.0\n" +"Project-Id-Version: Odoo Server 14.0\n" "Report-Msgid-Bugs-To: \n" "Last-Translator: \n" "Language-Team: \n" @@ -60,6 +60,27 @@ msgstr "" msgid "Description" msgstr "" +#. module: maintenance_timesheet +#: model:ir.model.fields,field_description:maintenance_timesheet.field_account_analytic_line__display_name +#: model:ir.model.fields,field_description:maintenance_timesheet.field_maintenance_equipment__display_name +#: model:ir.model.fields,field_description:maintenance_timesheet.field_maintenance_request__display_name +msgid "Display Name" +msgstr "" + +#. module: maintenance_timesheet +#: model:ir.model.fields,field_description:maintenance_timesheet.field_account_analytic_line__id +#: model:ir.model.fields,field_description:maintenance_timesheet.field_maintenance_equipment__id +#: model:ir.model.fields,field_description:maintenance_timesheet.field_maintenance_request__id +msgid "ID" +msgstr "" + +#. module: maintenance_timesheet +#: model:ir.model.fields,field_description:maintenance_timesheet.field_account_analytic_line____last_update +#: model:ir.model.fields,field_description:maintenance_timesheet.field_maintenance_equipment____last_update +#: model:ir.model.fields,field_description:maintenance_timesheet.field_maintenance_request____last_update +msgid "Last Modified on" +msgstr "" + #. module: maintenance_timesheet #: model:ir.model,name:maintenance_timesheet.model_maintenance_equipment msgid "Maintenance Equipment" diff --git a/maintenance_timesheet/models/maintenance_request.py b/maintenance_timesheet/models/maintenance_request.py index b7f851cee..8d13e5890 100644 --- a/maintenance_timesheet/models/maintenance_request.py +++ b/maintenance_timesheet/models/maintenance_request.py @@ -40,9 +40,9 @@ def action_view_timesheet_ids(self): could create timesheets for every employee """ self.ensure_one() - action = self.env.ref( + action = self.env["ir.actions.act_window"]._for_xml_id( "maintenance_timesheet.timesheet_action_from_request" - ).read()[0] + ) action["domain"] = [("maintenance_request_id", "=", self.id)] action["context"] = { "default_project_id": self.project_id.id, diff --git a/maintenance_timesheet/static/description/index.html b/maintenance_timesheet/static/description/index.html index 7c647f78b..8c776938c 100644 --- a/maintenance_timesheet/static/description/index.html +++ b/maintenance_timesheet/static/description/index.html @@ -367,7 +367,7 @@

Maintenance Timesheets

!! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: AGPL-3 OCA/maintenance Translate me on Weblate Try me on Runbot

+

Beta License: AGPL-3 OCA/maintenance Translate me on Weblate Try me on Runbot

This module adds timesheets to a request.

Table of contents

@@ -386,7 +386,7 @@

Bug Tracker

Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed -feedback.

+feedback.

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

@@ -411,7 +411,7 @@

Maintainers

OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

-

This module is part of the OCA/maintenance project on GitHub.

+

This module is part of the OCA/maintenance project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

diff --git a/maintenance_timesheet/tests/test_maintenance_timesheet.py b/maintenance_timesheet/tests/test_maintenance_timesheet.py index bd44491b6..6bd55eaa6 100644 --- a/maintenance_timesheet/tests/test_maintenance_timesheet.py +++ b/maintenance_timesheet/tests/test_maintenance_timesheet.py @@ -68,6 +68,17 @@ def test_check_request_done(self): }, ) ] + with self.assertRaises(ValidationError): + self.env["account.analytic.line"].create( + { + "name": "Attepting to create a task 2", + "project_id": self.request2.project_id.id, + "user_id": self.env.ref("base.user_admin").id, + "maintenance_request_id": self.request2.id, + "date": fields.Date.today(), + "unit_amount": 1, + } + ) with self.assertRaises(ValidationError): # Attempt to modify a timesheet related a done request for timesheet in self.request2.timesheet_ids: @@ -76,6 +87,10 @@ def test_check_request_done(self): # Attempt to delete a timesheet related a done request self.request2.timesheet_ids.unlink() + self.request2.stage_id = self.stage_undone + # Deleting timesheets is enabled again + self.request2.timesheet_ids.unlink() + def test_action_view_timesheet_ids(self): act1 = self.request2.action_view_timesheet_ids() self.assertEqual(act1["domain"][0][2], self.request2.id) @@ -84,3 +99,9 @@ def test_action_view_timesheet_ids(self): ) self.assertFalse(act1["context"]["default_task_id"]) self.assertFalse(act1["context"]["readonly_employee_id"]) + + def test_prepare_project_from_equipment_values(self): + data = self.env["maintenance.equipment"]._prepare_project_from_equipment_values( + {"name": "my name"} + ) + self.assertTrue(data["allow_timesheets"]) From ff75f5d728e4564964f817eafb246de2d981461c Mon Sep 17 00:00:00 2001 From: mymage Date: Wed, 28 Jul 2021 09:00:54 +0000 Subject: [PATCH 06/16] Added translation using Weblate (Italian) --- maintenance_timesheet/i18n/it.po | 130 +++++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 maintenance_timesheet/i18n/it.po diff --git a/maintenance_timesheet/i18n/it.po b/maintenance_timesheet/i18n/it.po new file mode 100644 index 000000000..d489a9066 --- /dev/null +++ b/maintenance_timesheet/i18n/it.po @@ -0,0 +1,130 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * maintenance_timesheet +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: Automatically generated\n" +"Language-Team: none\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" + +#. module: maintenance_timesheet +#: model_terms:ir.ui.view,arch_db:maintenance_timesheet.hr_equipment_request_view_form +msgid "Hours" +msgstr "" + +#. module: maintenance_timesheet +#: model_terms:ir.ui.view,arch_db:maintenance_timesheet.hr_equipment_request_view_kanban +msgid "Hours" +msgstr "" + +#. module: maintenance_timesheet +#: model_terms:ir.ui.view,arch_db:maintenance_timesheet.report_maintenance_request_document +msgid "Timesheet Entries" +msgstr "" + +#. module: maintenance_timesheet +#: model_terms:ir.ui.view,arch_db:maintenance_timesheet.report_maintenance_request_document +msgid "Timesheet Total Hours:" +msgstr "" + +#. module: maintenance_timesheet +#: model_terms:ir.ui.view,arch_db:maintenance_timesheet.report_maintenance_request_document +msgid "Total" +msgstr "" + +#. module: maintenance_timesheet +#: model:ir.model,name:maintenance_timesheet.model_account_analytic_line +msgid "Analytic Line" +msgstr "" + +#. module: maintenance_timesheet +#: code:addons/maintenance_timesheet/models/hr_timesheet.py:0 +#, python-format +msgid "" +"Cannot save or delete a timesheet for a maintenance request already done" +msgstr "" + +#. module: maintenance_timesheet +#: model_terms:ir.ui.view,arch_db:maintenance_timesheet.report_maintenance_request_document +msgid "Date" +msgstr "" + +#. module: maintenance_timesheet +#: model_terms:ir.ui.view,arch_db:maintenance_timesheet.report_maintenance_request_document +msgid "Description" +msgstr "" + +#. module: maintenance_timesheet +#: model:ir.model.fields,field_description:maintenance_timesheet.field_account_analytic_line__display_name +#: model:ir.model.fields,field_description:maintenance_timesheet.field_maintenance_equipment__display_name +#: model:ir.model.fields,field_description:maintenance_timesheet.field_maintenance_request__display_name +msgid "Display Name" +msgstr "" + +#. module: maintenance_timesheet +#: model:ir.model.fields,field_description:maintenance_timesheet.field_account_analytic_line__id +#: model:ir.model.fields,field_description:maintenance_timesheet.field_maintenance_equipment__id +#: model:ir.model.fields,field_description:maintenance_timesheet.field_maintenance_request__id +msgid "ID" +msgstr "" + +#. module: maintenance_timesheet +#: model:ir.model.fields,field_description:maintenance_timesheet.field_account_analytic_line____last_update +#: model:ir.model.fields,field_description:maintenance_timesheet.field_maintenance_equipment____last_update +#: model:ir.model.fields,field_description:maintenance_timesheet.field_maintenance_request____last_update +msgid "Last Modified on" +msgstr "" + +#. module: maintenance_timesheet +#: model:ir.model,name:maintenance_timesheet.model_maintenance_equipment +msgid "Maintenance Equipment" +msgstr "" + +#. module: maintenance_timesheet +#: model:ir.model,name:maintenance_timesheet.model_maintenance_request +#: model:ir.model.fields,field_description:maintenance_timesheet.field_account_analytic_line__maintenance_request_id +msgid "Maintenance Request" +msgstr "" + +#. module: maintenance_timesheet +#: model_terms:ir.ui.view,arch_db:maintenance_timesheet.report_maintenance_request_document +msgid "Project -" +msgstr "" + +#. module: maintenance_timesheet +#: model_terms:ir.ui.view,arch_db:maintenance_timesheet.hr_timesheet_line_search +msgid "Request" +msgstr "" + +#. module: maintenance_timesheet +#: model_terms:ir.ui.view,arch_db:maintenance_timesheet.report_maintenance_request_document +msgid "Responsible" +msgstr "" + +#. module: maintenance_timesheet +#: model_terms:ir.ui.view,arch_db:maintenance_timesheet.report_maintenance_request_document +msgid "Task" +msgstr "" + +#. module: maintenance_timesheet +#: model_terms:ir.ui.view,arch_db:maintenance_timesheet.report_maintenance_request_document +msgid "Time" +msgstr "" + +#. module: maintenance_timesheet +#: model:ir.model.fields,field_description:maintenance_timesheet.field_maintenance_request__timesheet_total_hours +msgid "Timesheet Total Hours" +msgstr "" + +#. module: maintenance_timesheet +#: model:ir.actions.act_window,name:maintenance_timesheet.timesheet_action_from_request +#: model:ir.model.fields,field_description:maintenance_timesheet.field_maintenance_request__timesheet_ids +msgid "Timesheets" +msgstr "" From 4911f4526d185787737c9375ffff9b6eff3de59f Mon Sep 17 00:00:00 2001 From: mymage Date: Wed, 28 Jul 2021 09:03:26 +0000 Subject: [PATCH 07/16] Translated using Weblate (Italian) Currently translated at 100.0% (21 of 21 strings) Translation: maintenance-14.0/maintenance-14.0-maintenance_timesheet Translate-URL: https://translation.odoo-community.org/projects/maintenance-14-0/maintenance-14-0-maintenance_timesheet/it/ --- maintenance_timesheet/i18n/it.po | 45 ++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/maintenance_timesheet/i18n/it.po b/maintenance_timesheet/i18n/it.po index d489a9066..c89caa84b 100644 --- a/maintenance_timesheet/i18n/it.po +++ b/maintenance_timesheet/i18n/it.po @@ -6,43 +6,46 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 14.0\n" "Report-Msgid-Bugs-To: \n" -"Last-Translator: Automatically generated\n" +"PO-Revision-Date: 2021-07-28 11:49+0000\n" +"Last-Translator: mymage \n" "Language-Team: none\n" "Language: it\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" "Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.3.2\n" #. module: maintenance_timesheet #: model_terms:ir.ui.view,arch_db:maintenance_timesheet.hr_equipment_request_view_form msgid "Hours" -msgstr "" +msgstr "Ore" #. module: maintenance_timesheet #: model_terms:ir.ui.view,arch_db:maintenance_timesheet.hr_equipment_request_view_kanban msgid "Hours" -msgstr "" +msgstr "Ore" #. module: maintenance_timesheet #: model_terms:ir.ui.view,arch_db:maintenance_timesheet.report_maintenance_request_document msgid "Timesheet Entries" msgstr "" +"Registrazioni foglio presenze" #. module: maintenance_timesheet #: model_terms:ir.ui.view,arch_db:maintenance_timesheet.report_maintenance_request_document msgid "Timesheet Total Hours:" -msgstr "" +msgstr "Ore totali foglio presenze:" #. module: maintenance_timesheet #: model_terms:ir.ui.view,arch_db:maintenance_timesheet.report_maintenance_request_document msgid "Total" -msgstr "" +msgstr "Totale" #. module: maintenance_timesheet #: model:ir.model,name:maintenance_timesheet.model_account_analytic_line msgid "Analytic Line" -msgstr "" +msgstr "Riga analitica" #. module: maintenance_timesheet #: code:addons/maintenance_timesheet/models/hr_timesheet.py:0 @@ -50,81 +53,83 @@ msgstr "" msgid "" "Cannot save or delete a timesheet for a maintenance request already done" msgstr "" +"Non si può salvare o cancellare un foglio presenze per una richiesta di " +"manutenzione già eseguita" #. module: maintenance_timesheet #: model_terms:ir.ui.view,arch_db:maintenance_timesheet.report_maintenance_request_document msgid "Date" -msgstr "" +msgstr "Data" #. module: maintenance_timesheet #: model_terms:ir.ui.view,arch_db:maintenance_timesheet.report_maintenance_request_document msgid "Description" -msgstr "" +msgstr "Descrizione" #. module: maintenance_timesheet #: model:ir.model.fields,field_description:maintenance_timesheet.field_account_analytic_line__display_name #: model:ir.model.fields,field_description:maintenance_timesheet.field_maintenance_equipment__display_name #: model:ir.model.fields,field_description:maintenance_timesheet.field_maintenance_request__display_name msgid "Display Name" -msgstr "" +msgstr "Nome visualizzato" #. module: maintenance_timesheet #: model:ir.model.fields,field_description:maintenance_timesheet.field_account_analytic_line__id #: model:ir.model.fields,field_description:maintenance_timesheet.field_maintenance_equipment__id #: model:ir.model.fields,field_description:maintenance_timesheet.field_maintenance_request__id msgid "ID" -msgstr "" +msgstr "ID" #. module: maintenance_timesheet #: model:ir.model.fields,field_description:maintenance_timesheet.field_account_analytic_line____last_update #: model:ir.model.fields,field_description:maintenance_timesheet.field_maintenance_equipment____last_update #: model:ir.model.fields,field_description:maintenance_timesheet.field_maintenance_request____last_update msgid "Last Modified on" -msgstr "" +msgstr "Ultima modifica il" #. module: maintenance_timesheet #: model:ir.model,name:maintenance_timesheet.model_maintenance_equipment msgid "Maintenance Equipment" -msgstr "" +msgstr "Attrezzatura manutenzione" #. module: maintenance_timesheet #: model:ir.model,name:maintenance_timesheet.model_maintenance_request #: model:ir.model.fields,field_description:maintenance_timesheet.field_account_analytic_line__maintenance_request_id msgid "Maintenance Request" -msgstr "" +msgstr "Richiesta manutenzione" #. module: maintenance_timesheet #: model_terms:ir.ui.view,arch_db:maintenance_timesheet.report_maintenance_request_document msgid "Project -" -msgstr "" +msgstr "Progetto -" #. module: maintenance_timesheet #: model_terms:ir.ui.view,arch_db:maintenance_timesheet.hr_timesheet_line_search msgid "Request" -msgstr "" +msgstr "Richiesta" #. module: maintenance_timesheet #: model_terms:ir.ui.view,arch_db:maintenance_timesheet.report_maintenance_request_document msgid "Responsible" -msgstr "" +msgstr "Responsabile" #. module: maintenance_timesheet #: model_terms:ir.ui.view,arch_db:maintenance_timesheet.report_maintenance_request_document msgid "Task" -msgstr "" +msgstr "Lavoro" #. module: maintenance_timesheet #: model_terms:ir.ui.view,arch_db:maintenance_timesheet.report_maintenance_request_document msgid "Time" -msgstr "" +msgstr "Tempo" #. module: maintenance_timesheet #: model:ir.model.fields,field_description:maintenance_timesheet.field_maintenance_request__timesheet_total_hours msgid "Timesheet Total Hours" -msgstr "" +msgstr "Ore totali foglio presenze" #. module: maintenance_timesheet #: model:ir.actions.act_window,name:maintenance_timesheet.timesheet_action_from_request #: model:ir.model.fields,field_description:maintenance_timesheet.field_maintenance_request__timesheet_ids msgid "Timesheets" -msgstr "" +msgstr "Foglio presenze" From caa162dbabf9f5333ae6782bb8cad9a51b16f084 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Mart=C3=ADnez?= Date: Wed, 21 Dec 2022 13:19:07 +0100 Subject: [PATCH 08/16] [IMP] maintenance_timesheet: Add timesheet page from maintenance request form view. TT40881 [UPD] Update maintenance_timesheet.pot maintenance_timesheet 14.0.2.1.0 Update translation files Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: maintenance-14.0/maintenance-14.0-maintenance_timesheet Translate-URL: https://translation.odoo-community.org/projects/maintenance-14-0/maintenance-14-0-maintenance_timesheet/ --- maintenance_timesheet/__manifest__.py | 2 +- maintenance_timesheet/i18n/es.po | 42 +++++++++++++ maintenance_timesheet/i18n/it.po | 21 +++++++ .../i18n/maintenance_timesheet.pot | 21 +++++++ .../migrations/14.0.2.0.0/pre-migration.py | 31 ++++++++++ .../models/maintenance_request.py | 30 +++++++++- .../views/maintenance_request_views.xml | 59 ++++++++++++++++++- 7 files changed, 203 insertions(+), 3 deletions(-) create mode 100644 maintenance_timesheet/migrations/14.0.2.0.0/pre-migration.py diff --git a/maintenance_timesheet/__manifest__.py b/maintenance_timesheet/__manifest__.py index d7a796bb4..3afcc5c9d 100644 --- a/maintenance_timesheet/__manifest__.py +++ b/maintenance_timesheet/__manifest__.py @@ -5,7 +5,7 @@ "summary": "Adds timesheets to maintenance requests", "author": "Odoo Community Association (OCA), Solvos", "license": "AGPL-3", - "version": "14.0.1.0.0", + "version": "14.0.2.1.0", "category": "Human Resources", "website": "https://github.com/OCA/maintenance", "depends": ["base_maintenance", "maintenance_project", "hr_timesheet"], diff --git a/maintenance_timesheet/i18n/es.po b/maintenance_timesheet/i18n/es.po index 48b8bb2e6..5db4be8cc 100644 --- a/maintenance_timesheet/i18n/es.po +++ b/maintenance_timesheet/i18n/es.po @@ -66,6 +66,32 @@ msgstr "" msgid "Description" msgstr "" +#. module: maintenance_timesheet +#: model:ir.model.fields,field_description:maintenance_timesheet.field_account_analytic_line__display_name +#: model:ir.model.fields,field_description:maintenance_timesheet.field_maintenance_equipment__display_name +#: model:ir.model.fields,field_description:maintenance_timesheet.field_maintenance_request__display_name +msgid "Display Name" +msgstr "" + +#. module: maintenance_timesheet +#: model_terms:ir.ui.view,arch_db:maintenance_timesheet.equipment_request_view_form +msgid "Duration (Hour(s))" +msgstr "" + +#. module: maintenance_timesheet +#: model:ir.model.fields,field_description:maintenance_timesheet.field_account_analytic_line__id +#: model:ir.model.fields,field_description:maintenance_timesheet.field_maintenance_equipment__id +#: model:ir.model.fields,field_description:maintenance_timesheet.field_maintenance_request__id +msgid "ID" +msgstr "" + +#. module: maintenance_timesheet +#: model:ir.model.fields,field_description:maintenance_timesheet.field_account_analytic_line____last_update +#: model:ir.model.fields,field_description:maintenance_timesheet.field_maintenance_equipment____last_update +#: model:ir.model.fields,field_description:maintenance_timesheet.field_maintenance_request____last_update +msgid "Last Modified on" +msgstr "" + #. module: maintenance_timesheet #: model:ir.model,name:maintenance_timesheet.model_maintenance_equipment msgid "Maintenance Equipment" @@ -77,11 +103,26 @@ msgstr "Equipo" msgid "Maintenance Request" msgstr "Petición de mantenimiento" +#. module: maintenance_timesheet +#: model:ir.model.fields,field_description:maintenance_timesheet.field_maintenance_request__planned_hours +msgid "Planned Hours" +msgstr "" + +#. module: maintenance_timesheet +#: model:ir.model.fields,field_description:maintenance_timesheet.field_maintenance_request__progress +msgid "Progress" +msgstr "" + #. module: maintenance_timesheet #: model_terms:ir.ui.view,arch_db:maintenance_timesheet.report_maintenance_request_document msgid "Project -" msgstr "" +#. module: maintenance_timesheet +#: model:ir.model.fields,field_description:maintenance_timesheet.field_maintenance_request__remaining_hours +msgid "Remaining Hours" +msgstr "" + #. module: maintenance_timesheet #: model_terms:ir.ui.view,arch_db:maintenance_timesheet.hr_timesheet_line_search msgid "Request" @@ -110,5 +151,6 @@ msgstr "Horas totales en partes de trabajo" #. module: maintenance_timesheet #: model:ir.actions.act_window,name:maintenance_timesheet.timesheet_action_from_request #: model:ir.model.fields,field_description:maintenance_timesheet.field_maintenance_request__timesheet_ids +#: model_terms:ir.ui.view,arch_db:maintenance_timesheet.equipment_request_view_form msgid "Timesheets" msgstr "Partes de trabajo" diff --git a/maintenance_timesheet/i18n/it.po b/maintenance_timesheet/i18n/it.po index c89caa84b..58bc7f351 100644 --- a/maintenance_timesheet/i18n/it.po +++ b/maintenance_timesheet/i18n/it.po @@ -73,6 +73,11 @@ msgstr "Descrizione" msgid "Display Name" msgstr "Nome visualizzato" +#. module: maintenance_timesheet +#: model_terms:ir.ui.view,arch_db:maintenance_timesheet.equipment_request_view_form +msgid "Duration (Hour(s))" +msgstr "" + #. module: maintenance_timesheet #: model:ir.model.fields,field_description:maintenance_timesheet.field_account_analytic_line__id #: model:ir.model.fields,field_description:maintenance_timesheet.field_maintenance_equipment__id @@ -98,11 +103,26 @@ msgstr "Attrezzatura manutenzione" msgid "Maintenance Request" msgstr "Richiesta manutenzione" +#. module: maintenance_timesheet +#: model:ir.model.fields,field_description:maintenance_timesheet.field_maintenance_request__planned_hours +msgid "Planned Hours" +msgstr "" + +#. module: maintenance_timesheet +#: model:ir.model.fields,field_description:maintenance_timesheet.field_maintenance_request__progress +msgid "Progress" +msgstr "" + #. module: maintenance_timesheet #: model_terms:ir.ui.view,arch_db:maintenance_timesheet.report_maintenance_request_document msgid "Project -" msgstr "Progetto -" +#. module: maintenance_timesheet +#: model:ir.model.fields,field_description:maintenance_timesheet.field_maintenance_request__remaining_hours +msgid "Remaining Hours" +msgstr "" + #. module: maintenance_timesheet #: model_terms:ir.ui.view,arch_db:maintenance_timesheet.hr_timesheet_line_search msgid "Request" @@ -131,5 +151,6 @@ msgstr "Ore totali foglio presenze" #. module: maintenance_timesheet #: model:ir.actions.act_window,name:maintenance_timesheet.timesheet_action_from_request #: model:ir.model.fields,field_description:maintenance_timesheet.field_maintenance_request__timesheet_ids +#: model_terms:ir.ui.view,arch_db:maintenance_timesheet.equipment_request_view_form msgid "Timesheets" msgstr "Foglio presenze" diff --git a/maintenance_timesheet/i18n/maintenance_timesheet.pot b/maintenance_timesheet/i18n/maintenance_timesheet.pot index 1e20aca9a..a4f947b69 100644 --- a/maintenance_timesheet/i18n/maintenance_timesheet.pot +++ b/maintenance_timesheet/i18n/maintenance_timesheet.pot @@ -67,6 +67,11 @@ msgstr "" msgid "Display Name" msgstr "" +#. module: maintenance_timesheet +#: model_terms:ir.ui.view,arch_db:maintenance_timesheet.equipment_request_view_form +msgid "Duration (Hour(s))" +msgstr "" + #. module: maintenance_timesheet #: model:ir.model.fields,field_description:maintenance_timesheet.field_account_analytic_line__id #: model:ir.model.fields,field_description:maintenance_timesheet.field_maintenance_equipment__id @@ -92,11 +97,26 @@ msgstr "" msgid "Maintenance Request" msgstr "" +#. module: maintenance_timesheet +#: model:ir.model.fields,field_description:maintenance_timesheet.field_maintenance_request__planned_hours +msgid "Planned Hours" +msgstr "" + +#. module: maintenance_timesheet +#: model:ir.model.fields,field_description:maintenance_timesheet.field_maintenance_request__progress +msgid "Progress" +msgstr "" + #. module: maintenance_timesheet #: model_terms:ir.ui.view,arch_db:maintenance_timesheet.report_maintenance_request_document msgid "Project -" msgstr "" +#. module: maintenance_timesheet +#: model:ir.model.fields,field_description:maintenance_timesheet.field_maintenance_request__remaining_hours +msgid "Remaining Hours" +msgstr "" + #. module: maintenance_timesheet #: model_terms:ir.ui.view,arch_db:maintenance_timesheet.hr_timesheet_line_search msgid "Request" @@ -125,5 +145,6 @@ msgstr "" #. module: maintenance_timesheet #: model:ir.actions.act_window,name:maintenance_timesheet.timesheet_action_from_request #: model:ir.model.fields,field_description:maintenance_timesheet.field_maintenance_request__timesheet_ids +#: model_terms:ir.ui.view,arch_db:maintenance_timesheet.equipment_request_view_form msgid "Timesheets" msgstr "" diff --git a/maintenance_timesheet/migrations/14.0.2.0.0/pre-migration.py b/maintenance_timesheet/migrations/14.0.2.0.0/pre-migration.py new file mode 100644 index 000000000..5fc14c44c --- /dev/null +++ b/maintenance_timesheet/migrations/14.0.2.0.0/pre-migration.py @@ -0,0 +1,31 @@ +# Copyright 2022 Tecnativa - Víctor Martínez +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from openupgradelib import openupgrade + + +@openupgrade.migrate() +def migrate(env, version): + if not openupgrade.column_exists( + env.cr, "maintenance_request", "timesheet_total_hours" + ): + openupgrade.logged_query( + env.cr, + """ALTER TABLE maintenance_request + ADD COLUMN timesheet_total_hours float + """, + ) + openupgrade.logged_query( + env.cr, + """ + UPDATE maintenance_request + SET timesheet_total_hours=coalesce(tt.total_unit_amount, 0.0) + FROM ( + SELECT mr.id, SUM(aal.unit_amount) total_unit_amount + FROM maintenance_request mr + LEFT JOIN account_analytic_line aal ON aal.maintenance_request_id = mr.id + GROUP BY mr.id + ) AS tt + WHERE maintenance_request.id = tt.id + """, + ) diff --git a/maintenance_timesheet/models/maintenance_request.py b/maintenance_timesheet/models/maintenance_request.py index 8d13e5890..539a55d8a 100644 --- a/maintenance_timesheet/models/maintenance_request.py +++ b/maintenance_timesheet/models/maintenance_request.py @@ -12,7 +12,35 @@ class MaintenanceRequest(models.Model): comodel_name="account.analytic.line", inverse_name="maintenance_request_id", ) - timesheet_total_hours = fields.Float(compute="_compute_timesheet_total_hours") + timesheet_total_hours = fields.Float( + compute="_compute_timesheet_total_hours", readonly=True, store=True + ) + planned_hours = fields.Float(string="Planned Hours", tracking=True) + progress = fields.Float( + compute="_compute_progress_hours", + group_operator="avg", + store=True, + string="Progress", + ) + remaining_hours = fields.Float( + compute="_compute_progress_hours", + readonly=True, + store=True, + string="Remaining Hours", + ) + + @api.depends("planned_hours", "timesheet_total_hours") + def _compute_progress_hours(self): + for item in self: + item.progress = 0.0 + if item.planned_hours > 0.0: + if item.timesheet_total_hours > item.planned_hours: + item.progress = 100 + else: + item.progress = round( + 100.0 * item.timesheet_total_hours / item.planned_hours, 2 + ) + item.remaining_hours = item.planned_hours - item.timesheet_total_hours def _add_followers(self): """ diff --git a/maintenance_timesheet/views/maintenance_request_views.xml b/maintenance_timesheet/views/maintenance_request_views.xml index 2cf38393f..5acb6ee94 100644 --- a/maintenance_timesheet/views/maintenance_request_views.xml +++ b/maintenance_timesheet/views/maintenance_request_views.xml @@ -74,7 +74,7 @@ maintenance.request - +