diff --git a/repair_timesheet/README.rst b/repair_timesheet/README.rst new file mode 100644 index 00000000..ce4b1d74 --- /dev/null +++ b/repair_timesheet/README.rst @@ -0,0 +1,101 @@ +================ +Repair Timesheet +================ + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:c2e64dc6606c845bb75e06ed854b15fc84a222c2d97408272e22e530092f5b86 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Frepair-lightgray.png?logo=github + :target: https://github.com/OCA/repair/tree/17.0/repair_timesheet + :alt: OCA/repair +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/repair-17-0/repair-17-0-repair_timesheet + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/repair&target_branch=17.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module integrates timesheet tracking with repair orders. It adds a +"Timesheets" tab to the repair order form, allowing users to log and +track the time spent on each repair through timesheet entries. Users can +record detailed timesheet data, such as the project, task, date, and +duration for each repair. Additionally, the module automatically +calculates the total hours spent on repairs and displays this +information in both the form view and the list view of repair orders. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +When creating or editing a repair order, you will find a new Timesheets +tab within the repair order form. In this tab, you can log and track the +time spent on the repair by adding timesheet entries. Each entry allows +you to specify the project, task, date, and the time spent on the repair +in hours and minutes. + +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 to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* APSL-Nagarro + +Contributors +------------ + +- `APSL-Nagarro `__: + + - Patryk Pyczko + +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. + +.. |maintainer-ppyczko| image:: https://github.com/ppyczko.png?size=40px + :target: https://github.com/ppyczko + :alt: ppyczko + +Current `maintainer `__: + +|maintainer-ppyczko| + +This module is part of the `OCA/repair `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/repair_timesheet/__init__.py b/repair_timesheet/__init__.py new file mode 100644 index 00000000..31660d6a --- /dev/null +++ b/repair_timesheet/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import models diff --git a/repair_timesheet/__manifest__.py b/repair_timesheet/__manifest__.py new file mode 100644 index 00000000..8ba826be --- /dev/null +++ b/repair_timesheet/__manifest__.py @@ -0,0 +1,16 @@ +# Copyright 2024 Patryk Pyczko (APSL-Nagarro) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Repair Timesheet", + "version": "17.0.1.0.0", + "category": "Repair", + "website": "https://github.com/OCA/repair", + "author": "APSL-Nagarro, Odoo Community Association (OCA)", + "maintainers": ["ppyczko"], + "license": "AGPL-3", + "application": False, + "installable": True, + "depends": ["repair", "hr_timesheet"], + "data": ["views/repair_views.xml"], +} diff --git a/repair_timesheet/i18n/ca.po b/repair_timesheet/i18n/ca.po new file mode 100644 index 00000000..c9698c7b --- /dev/null +++ b/repair_timesheet/i18n/ca.po @@ -0,0 +1,57 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * repair_timesheet +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-10-16 08:59+0000\n" +"PO-Revision-Date: 2024-10-16 08:59+0000\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: repair_timesheet +#: model:ir.model,name:repair_timesheet.model_account_analytic_line +msgid "Analytic Line" +msgstr "Línia analítica" + +#. module: repair_timesheet +#: model_terms:ir.ui.view,arch_db:repair_timesheet.repair_order_form_view_timesheet_inherit +msgid "Duration (Hour(s))" +msgstr "Durada (Hora/es)" + +#. module: repair_timesheet +#: model:ir.model.fields,field_description:repair_timesheet.field_account_analytic_line__repair_order_id +msgid "Related Repair Order" +msgstr "Ordre de reparació relacionada" + +#. module: repair_timesheet +#: model:ir.model,name:repair_timesheet.model_repair_order +msgid "Repair Order" +msgstr "Ordre de reparació" + +#. module: repair_timesheet +#: model:ir.model.fields,help:repair_timesheet.field_account_analytic_line__repair_order_id +msgid "The repair order related to this timesheet entry." +msgstr "L'ordre de reparació relacionada amb aquesta entrada de full d'hores." + +#. module: repair_timesheet +#: model:ir.model.fields,field_description:repair_timesheet.field_repair_order__timesheet_ids +#: model_terms:ir.ui.view,arch_db:repair_timesheet.repair_order_form_view_timesheet_inherit +msgid "Timesheets" +msgstr "Fulls d'hores" + +#. module: repair_timesheet +#: model:ir.model.fields,field_description:repair_timesheet.field_repair_order__timesheet_total_hours +msgid "Total Hours" +msgstr "Hores totals" + +#. module: repair_timesheet +#: model:ir.model.fields,help:repair_timesheet.field_repair_order__timesheet_total_hours +msgid "Total hours spent on this repair order." +msgstr "Hores totals dedicades a aquesta ordre de reparació." diff --git a/repair_timesheet/i18n/es.po b/repair_timesheet/i18n/es.po new file mode 100644 index 00000000..fa73a074 --- /dev/null +++ b/repair_timesheet/i18n/es.po @@ -0,0 +1,57 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * repair_timesheet +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-10-16 09:00+0000\n" +"PO-Revision-Date: 2024-10-16 09:00+0000\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: repair_timesheet +#: model:ir.model,name:repair_timesheet.model_account_analytic_line +msgid "Analytic Line" +msgstr "Línea analítica" + +#. module: repair_timesheet +#: model_terms:ir.ui.view,arch_db:repair_timesheet.repair_order_form_view_timesheet_inherit +msgid "Duration (Hour(s))" +msgstr "Duración (Hora/s)" + +#. module: repair_timesheet +#: model:ir.model.fields,field_description:repair_timesheet.field_account_analytic_line__repair_order_id +msgid "Related Repair Order" +msgstr "Orden de reparación relacionada" + +#. module: repair_timesheet +#: model:ir.model,name:repair_timesheet.model_repair_order +msgid "Repair Order" +msgstr "Orden de reparación" + +#. module: repair_timesheet +#: model:ir.model.fields,help:repair_timesheet.field_account_analytic_line__repair_order_id +msgid "The repair order related to this timesheet entry." +msgstr "La orden de reparación relacionada con esta entrada de parte de horas." + +#. module: repair_timesheet +#: model:ir.model.fields,field_description:repair_timesheet.field_repair_order__timesheet_ids +#: model_terms:ir.ui.view,arch_db:repair_timesheet.repair_order_form_view_timesheet_inherit +msgid "Timesheets" +msgstr "Partes de horas" + +#. module: repair_timesheet +#: model:ir.model.fields,field_description:repair_timesheet.field_repair_order__timesheet_total_hours +msgid "Total Hours" +msgstr "Horas totales" + +#. module: repair_timesheet +#: model:ir.model.fields,help:repair_timesheet.field_repair_order__timesheet_total_hours +msgid "Total hours spent on this repair order." +msgstr "Horas totales dedicadas a esta orden de reparación." diff --git a/repair_timesheet/models/__init__.py b/repair_timesheet/models/__init__.py new file mode 100644 index 00000000..611c2acd --- /dev/null +++ b/repair_timesheet/models/__init__.py @@ -0,0 +1,4 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import repair +from . import hr_timesheet diff --git a/repair_timesheet/models/hr_timesheet.py b/repair_timesheet/models/hr_timesheet.py new file mode 100644 index 00000000..e3fe8770 --- /dev/null +++ b/repair_timesheet/models/hr_timesheet.py @@ -0,0 +1,14 @@ +# Copyright 2024 Patryk Pyczko (APSL-Nagarro) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class AccountAnalyticLine(models.Model): + _inherit = "account.analytic.line" + + repair_order_id = fields.Many2one( + "repair.order", + string="Related Repair Order", + help="The repair order related to this timesheet entry.", + ) diff --git a/repair_timesheet/models/repair.py b/repair_timesheet/models/repair.py new file mode 100644 index 00000000..bcd6d482 --- /dev/null +++ b/repair_timesheet/models/repair.py @@ -0,0 +1,23 @@ +# Copyright 2024 Patryk Pyczko (APSL-Nagarro) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class RepairOrder(models.Model): + _inherit = "repair.order" + + timesheet_ids = fields.One2many( + "account.analytic.line", "repair_order_id", string="Timesheets" + ) + timesheet_total_hours = fields.Float( + string="Total Hours", + compute="_compute_timesheet_total_hours", + store=True, + help="Total hours spent on this repair order.", + ) + + @api.depends("timesheet_ids.unit_amount") + def _compute_timesheet_total_hours(self): + for order in self: + order.timesheet_total_hours = sum(order.timesheet_ids.mapped("unit_amount")) diff --git a/repair_timesheet/pyproject.toml b/repair_timesheet/pyproject.toml new file mode 100644 index 00000000..4231d0cc --- /dev/null +++ b/repair_timesheet/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/repair_timesheet/readme/CONTRIBUTORS.md b/repair_timesheet/readme/CONTRIBUTORS.md new file mode 100644 index 00000000..f413e101 --- /dev/null +++ b/repair_timesheet/readme/CONTRIBUTORS.md @@ -0,0 +1,3 @@ +- [APSL-Nagarro](https://apsl.tech): + + > - Patryk Pyczko \<\> diff --git a/repair_timesheet/readme/DESCRIPTION.md b/repair_timesheet/readme/DESCRIPTION.md new file mode 100644 index 00000000..2ae63756 --- /dev/null +++ b/repair_timesheet/readme/DESCRIPTION.md @@ -0,0 +1 @@ +This module integrates timesheet tracking with repair orders. It adds a "Timesheets" tab to the repair order form, allowing users to log and track the time spent on each repair through timesheet entries. Users can record detailed timesheet data, such as the project, task, date, and duration for each repair. Additionally, the module automatically calculates the total hours spent on repairs and displays this information in both the form view and the list view of repair orders. \ No newline at end of file diff --git a/repair_timesheet/readme/USAGE.md b/repair_timesheet/readme/USAGE.md new file mode 100644 index 00000000..0d095e40 --- /dev/null +++ b/repair_timesheet/readme/USAGE.md @@ -0,0 +1 @@ +When creating or editing a repair order, you will find a new Timesheets tab within the repair order form. In this tab, you can log and track the time spent on the repair by adding timesheet entries. Each entry allows you to specify the project, task, date, and the time spent on the repair in hours and minutes. \ No newline at end of file diff --git a/repair_timesheet/static/description/icon.png b/repair_timesheet/static/description/icon.png new file mode 100644 index 00000000..3a0328b5 Binary files /dev/null and b/repair_timesheet/static/description/icon.png differ diff --git a/repair_timesheet/static/description/icon.svg b/repair_timesheet/static/description/icon.svg new file mode 100644 index 00000000..a7a26d09 --- /dev/null +++ b/repair_timesheet/static/description/icon.svg @@ -0,0 +1,79 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/repair_timesheet/static/description/index.html b/repair_timesheet/static/description/index.html new file mode 100644 index 00000000..f92d18ab --- /dev/null +++ b/repair_timesheet/static/description/index.html @@ -0,0 +1,124 @@ +
+
+
+

Module name

+

This module was written to extend the functionality of ... to support ... and allow you to ...

+
+
+
+ +
+
+
+

Installation

+
+
+

To install this module, you need to: +

    +
  • ...
  • +
+

+
+
+
+ + + +
+
+
+
+ +
+
+
+

Configuration

+
+
+

To configure this module, you need to: +

    +
  • ...
  • +
+

+
+
+
+ + + +
+
+
+
+ +
+
+
+

Usage

+
+
+

To use this module, you need to: +

    +
  • ...
  • +
+

+

For further information, please visit: +

+

+
+
+
+ + + +
+
+
+
+ +
+
+
+

Known issues / Roadmap

+
+
+

+

    +
  • ...
  • +
+

+
+
+
+ + + +
+
+
+
+ +
+
+
+

Credits

+
+
+

Contributors

+ +
+
+

Maintainer

+

+ This module is maintained by the OCA.
+ 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.
+ To contribute to this module, please visit http://odoo-community.org.
+ +

+
+
+
diff --git a/repair_timesheet/tests/__init__.py b/repair_timesheet/tests/__init__.py new file mode 100644 index 00000000..05dc4eeb --- /dev/null +++ b/repair_timesheet/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import test_repair_timesheet diff --git a/repair_timesheet/tests/test_repair_timesheet.py b/repair_timesheet/tests/test_repair_timesheet.py new file mode 100644 index 00000000..cee22404 --- /dev/null +++ b/repair_timesheet/tests/test_repair_timesheet.py @@ -0,0 +1,75 @@ +# Copyright 2024 Patryk Pyczko (APSL-Nagarro) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + + +from odoo.tests.common import TransactionCase + + +class TestRepairOrderTimesheetTotalHours(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + + cls.repair_order = cls.env["repair.order"].create( + { + "name": "Test Repair Order", + } + ) + + def test_no_timesheets(self): + """Test total hours when no timesheets are associated""" + self.assertEqual( + self.repair_order.timesheet_total_hours, + 0, + "Total hours should be 0 when there are no timesheets.", + ) + + def test_one_timesheet(self): + """Test total hours with one timesheet""" + self.env["account.analytic.line"].create( + { + "repair_order_id": self.repair_order.id, + "unit_amount": 5.0, + "name": "Timesheet 1", + } + ) + + self.repair_order._compute_timesheet_total_hours() + + self.assertEqual( + self.repair_order.timesheet_total_hours, + 5.0, + "Total hours should be 5 with one timesheet entry.", + ) + + def test_multiple_timesheets(self): + """Test total hours with multiple timesheets""" + self.env["account.analytic.line"].create( + { + "repair_order_id": self.repair_order.id, + "unit_amount": 3.0, + "name": "Timesheet 1", + } + ) + self.env["account.analytic.line"].create( + { + "repair_order_id": self.repair_order.id, + "unit_amount": 2.5, + "name": "Timesheet 2", + } + ) + self.env["account.analytic.line"].create( + { + "repair_order_id": self.repair_order.id, + "unit_amount": 1.5, + "name": "Timesheet 3", + } + ) + + self.repair_order._compute_timesheet_total_hours() + + self.assertEqual( + self.repair_order.timesheet_total_hours, + 7.0, + "Total hours should be 7 (3 + 2.5 + 1.5) with multiple timesheets.", + ) diff --git a/repair_timesheet/views/repair_views.xml b/repair_timesheet/views/repair_views.xml new file mode 100644 index 00000000..cb52d781 --- /dev/null +++ b/repair_timesheet/views/repair_views.xml @@ -0,0 +1,44 @@ + + + + repair.order.form.view.timesheet + repair.order + + + + + + + + + + + + + + + + + + + + + + + + + + repair.order.tree.view.timesheet + repair.order + + + + + + + +