diff --git a/quality_control_oca_timesheet/README.rst b/quality_control_oca_timesheet/README.rst new file mode 100644 index 000000000..f6e99fe9d --- /dev/null +++ b/quality_control_oca_timesheet/README.rst @@ -0,0 +1,102 @@ +================================= +Quality Control - Timesheet (OCA) +================================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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%2Fmanufacture-lightgray.png?logo=github + :target: https://github.com/OCA/manufacture/tree/17.0/quality_control_oca_timesheet + :alt: OCA/manufacture +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/manufacture-17-0/manufacture-17-0-quality_control_oca_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/manufacture&target_branch=17.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module integrates timesheet tracking with quality control +inspections. It adds a "Timesheets" tab to the quality control +inspection form, allowing users to log and track the time spent on each +inspection through timesheet entries. Users can record detailed +timesheet data, such as the project, task, date, and duration for each +inspection. Additionally, the module automatically calculates the total +hours spent on inspections and displays this information in both the +form view and the list view of quality control inspections. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +When creating or editing a quality control inspection, you will find a +new Timesheets tab within the inspection form. In this tab, you can log +and track the time spent on the inspection by adding timesheet entries. +Each entry allows you to specify the project, task, date, and the time +spent on the inspection 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/manufacture `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/quality_control_oca_timesheet/__init__.py b/quality_control_oca_timesheet/__init__.py new file mode 100644 index 000000000..31660d6a9 --- /dev/null +++ b/quality_control_oca_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/quality_control_oca_timesheet/__manifest__.py b/quality_control_oca_timesheet/__manifest__.py new file mode 100644 index 000000000..7043baa2b --- /dev/null +++ b/quality_control_oca_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": "Quality Control - Timesheet (OCA)", + "version": "17.0.1.0.0", + "category": "Quality Control", + "website": "https://github.com/OCA/manufacture", + "author": "APSL-Nagarro, Odoo Community Association (OCA)", + "maintainers": ["ppyczko"], + "license": "AGPL-3", + "application": False, + "installable": True, + "depends": ["quality_control_oca", "hr_timesheet"], + "data": ["views/qc_inspection_view.xml"], +} diff --git a/quality_control_oca_timesheet/i18n/ca.po b/quality_control_oca_timesheet/i18n/ca.po new file mode 100644 index 000000000..ce977e2c0 --- /dev/null +++ b/quality_control_oca_timesheet/i18n/ca.po @@ -0,0 +1,59 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * quality_control_oca_timesheet +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-10-15 11:09+0000\n" +"PO-Revision-Date: 2024-10-15 11:09+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: quality_control_oca_timesheet +#: model:ir.model,name:quality_control_oca_timesheet.model_account_analytic_line +msgid "Analytic Line" +msgstr "Línia analítica" + +#. module: quality_control_oca_timesheet +#: model_terms:ir.ui.view,arch_db:quality_control_oca_timesheet.qc_inspection_form_view_timesheet_inherit +msgid "Duration (Hour(s))" +msgstr "Durada (Hora/es)" + +#. module: quality_control_oca_timesheet +#: model:ir.model,name:quality_control_oca_timesheet.model_qc_inspection +msgid "Quality control inspection" +msgstr "Inspecció de control de qualitat" + +#. module: quality_control_oca_timesheet +#: model:ir.model.fields,field_description:quality_control_oca_timesheet.field_account_analytic_line__qc_inspection_id +msgid "Related QC Inspection" +msgstr "Inspecció de QC relacionada" + +#. module: quality_control_oca_timesheet +#: model:ir.model.fields,help:quality_control_oca_timesheet.field_account_analytic_line__qc_inspection_id +msgid "The quality control inspection related to this timesheet entry." +msgstr "La inspecció de control de qualitat relacionada amb aquesta entrada de full d'hores." + +#. module: quality_control_oca_timesheet +#: model:ir.model.fields,field_description:quality_control_oca_timesheet.field_qc_inspection__timesheet_ids +#: model_terms:ir.ui.view,arch_db:quality_control_oca_timesheet.qc_inspection_form_view_timesheet_inherit +msgid "Timesheets" +msgstr "Fulls d'hores" + +#. module: quality_control_oca_timesheet +#: model:ir.model.fields,field_description:quality_control_oca_timesheet.field_qc_inspection__timesheet_total_hours +#: model_terms:ir.ui.view,arch_db:quality_control_oca_timesheet.qc_inspection_form_view_timesheet_inherit +#: model_terms:ir.ui.view,arch_db:quality_control_oca_timesheet.qc_inspection_tree_view_timesheet_inherit +msgid "Total Hours" +msgstr "Hores totals" + +#. module: quality_control_oca_timesheet +#: model:ir.model.fields,help:quality_control_oca_timesheet.field_qc_inspection__timesheet_total_hours +msgid "Total hours spent on this quality control inspection." +msgstr "Hores totals dedicades a aquesta inspecció de control de qualitat." diff --git a/quality_control_oca_timesheet/i18n/es.po b/quality_control_oca_timesheet/i18n/es.po new file mode 100644 index 000000000..5490e6e9b --- /dev/null +++ b/quality_control_oca_timesheet/i18n/es.po @@ -0,0 +1,59 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * quality_control_oca_timesheet +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-10-15 11:10+0000\n" +"PO-Revision-Date: 2024-10-15 11:10+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: quality_control_oca_timesheet +#: model:ir.model,name:quality_control_oca_timesheet.model_account_analytic_line +msgid "Analytic Line" +msgstr "Línea analítica" + +#. module: quality_control_oca_timesheet +#: model_terms:ir.ui.view,arch_db:quality_control_oca_timesheet.qc_inspection_form_view_timesheet_inherit +msgid "Duration (Hour(s))" +msgstr "Duración (Hora/s)" + +#. module: quality_control_oca_timesheet +#: model:ir.model,name:quality_control_oca_timesheet.model_qc_inspection +msgid "Quality control inspection" +msgstr "Inspección del control de calidad" + +#. module: quality_control_oca_timesheet +#: model:ir.model.fields,field_description:quality_control_oca_timesheet.field_account_analytic_line__qc_inspection_id +msgid "Related QC Inspection" +msgstr "Inspección de QC relacionada" + +#. module: quality_control_oca_timesheet +#: model:ir.model.fields,help:quality_control_oca_timesheet.field_account_analytic_line__qc_inspection_id +msgid "The quality control inspection related to this timesheet entry." +msgstr "La inspección de control de calidad relacionada con esta entrada de parte de horas." + +#. module: quality_control_oca_timesheet +#: model:ir.model.fields,field_description:quality_control_oca_timesheet.field_qc_inspection__timesheet_ids +#: model_terms:ir.ui.view,arch_db:quality_control_oca_timesheet.qc_inspection_form_view_timesheet_inherit +msgid "Timesheets" +msgstr "Partes de horas" + +#. module: quality_control_oca_timesheet +#: model:ir.model.fields,field_description:quality_control_oca_timesheet.field_qc_inspection__timesheet_total_hours +#: model_terms:ir.ui.view,arch_db:quality_control_oca_timesheet.qc_inspection_form_view_timesheet_inherit +#: model_terms:ir.ui.view,arch_db:quality_control_oca_timesheet.qc_inspection_tree_view_timesheet_inherit +msgid "Total Hours" +msgstr "Horas totales" + +#. module: quality_control_oca_timesheet +#: model:ir.model.fields,help:quality_control_oca_timesheet.field_qc_inspection__timesheet_total_hours +msgid "Total hours spent on this quality control inspection." +msgstr "Horas totales dedicadas a esta inspección de control de calidad." diff --git a/quality_control_oca_timesheet/models/__init__.py b/quality_control_oca_timesheet/models/__init__.py new file mode 100644 index 000000000..cd0cc7efa --- /dev/null +++ b/quality_control_oca_timesheet/models/__init__.py @@ -0,0 +1,4 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import qc_inspection +from . import hr_timesheet diff --git a/quality_control_oca_timesheet/models/hr_timesheet.py b/quality_control_oca_timesheet/models/hr_timesheet.py new file mode 100644 index 000000000..a1211ee25 --- /dev/null +++ b/quality_control_oca_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" + + qc_inspection_id = fields.Many2one( + "qc.inspection", + string="Related QC Inspection", + help="The quality control inspection related to this timesheet entry.", + ) diff --git a/quality_control_oca_timesheet/models/qc_inspection.py b/quality_control_oca_timesheet/models/qc_inspection.py new file mode 100644 index 000000000..c438226b3 --- /dev/null +++ b/quality_control_oca_timesheet/models/qc_inspection.py @@ -0,0 +1,28 @@ +# 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 QcInspection(models.Model): + _inherit = "qc.inspection" + + timesheet_ids = fields.One2many( + "account.analytic.line", + "qc_inspection_id", + string="Timesheets", + ) + + timesheet_total_hours = fields.Float( + string="Total Hours", + compute="_compute_timesheet_total_hours", + store=True, + help="Total hours spent on this quality control inspection.", + ) + + @api.depends("timesheet_ids.unit_amount") + def _compute_timesheet_total_hours(self): + for inspection in self: + inspection.timesheet_total_hours = sum( + inspection.timesheet_ids.mapped("unit_amount") + ) diff --git a/quality_control_oca_timesheet/pyproject.toml b/quality_control_oca_timesheet/pyproject.toml new file mode 100644 index 000000000..4231d0ccc --- /dev/null +++ b/quality_control_oca_timesheet/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/quality_control_oca_timesheet/readme/CONTRIBUTORS.md b/quality_control_oca_timesheet/readme/CONTRIBUTORS.md new file mode 100644 index 000000000..f413e1013 --- /dev/null +++ b/quality_control_oca_timesheet/readme/CONTRIBUTORS.md @@ -0,0 +1,3 @@ +- [APSL-Nagarro](https://apsl.tech): + + > - Patryk Pyczko \<\> diff --git a/quality_control_oca_timesheet/readme/DESCRIPTION.md b/quality_control_oca_timesheet/readme/DESCRIPTION.md new file mode 100644 index 000000000..5a2ef80d3 --- /dev/null +++ b/quality_control_oca_timesheet/readme/DESCRIPTION.md @@ -0,0 +1 @@ +This module integrates timesheet tracking with quality control inspections. It adds a "Timesheets" tab to the quality control inspection form, allowing users to log and track the time spent on each inspection through timesheet entries. Users can record detailed timesheet data, such as the project, task, date, and duration for each inspection. Additionally, the module automatically calculates the total hours spent on inspections and displays this information in both the form view and the list view of quality control inspections. \ No newline at end of file diff --git a/quality_control_oca_timesheet/readme/USAGE.md b/quality_control_oca_timesheet/readme/USAGE.md new file mode 100644 index 000000000..c42f2929f --- /dev/null +++ b/quality_control_oca_timesheet/readme/USAGE.md @@ -0,0 +1 @@ +When creating or editing a quality control inspection, you will find a new Timesheets tab within the inspection form. In this tab, you can log and track the time spent on the inspection by adding timesheet entries. Each entry allows you to specify the project, task, date, and the time spent on the inspection in hours and minutes. \ No newline at end of file diff --git a/quality_control_oca_timesheet/static/description/icon.png b/quality_control_oca_timesheet/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/quality_control_oca_timesheet/static/description/icon.png differ diff --git a/quality_control_oca_timesheet/static/description/icon.svg b/quality_control_oca_timesheet/static/description/icon.svg new file mode 100644 index 000000000..a7a26d093 --- /dev/null +++ b/quality_control_oca_timesheet/static/description/icon.svg @@ -0,0 +1,79 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/quality_control_oca_timesheet/static/description/index.html b/quality_control_oca_timesheet/static/description/index.html new file mode 100644 index 000000000..f92d18ab8 --- /dev/null +++ b/quality_control_oca_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/quality_control_oca_timesheet/tests/__init__.py b/quality_control_oca_timesheet/tests/__init__.py new file mode 100644 index 000000000..8ccb23e25 --- /dev/null +++ b/quality_control_oca_timesheet/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import test_quality_control_oca_timesheet diff --git a/quality_control_oca_timesheet/tests/test_quality_control_oca_timesheet.py b/quality_control_oca_timesheet/tests/test_quality_control_oca_timesheet.py new file mode 100644 index 000000000..2edbb83d1 --- /dev/null +++ b/quality_control_oca_timesheet/tests/test_quality_control_oca_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 TestQcInspectionTimesheetTotalHours(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + + cls.qc_inspection = cls.env["qc.inspection"].create( + { + "name": "Test Inspection", + } + ) + + def test_no_timesheets(self): + """Test total hours when no timesheets are associated""" + self.assertEqual( + self.qc_inspection.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( + { + "qc_inspection_id": self.qc_inspection.id, + "unit_amount": 5.0, + "name": "Timesheet 1", + } + ) + + self.qc_inspection._compute_timesheet_total_hours() + + self.assertEqual( + self.qc_inspection.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( + { + "qc_inspection_id": self.qc_inspection.id, + "unit_amount": 3.0, + "name": "Timesheet 1", + } + ) + self.env["account.analytic.line"].create( + { + "qc_inspection_id": self.qc_inspection.id, + "unit_amount": 2.5, + "name": "Timesheet 2", + } + ) + self.env["account.analytic.line"].create( + { + "qc_inspection_id": self.qc_inspection.id, + "unit_amount": 1.5, + "name": "Timesheet 3", + } + ) + + self.qc_inspection._compute_timesheet_total_hours() + + self.assertEqual( + self.qc_inspection.timesheet_total_hours, + 7.0, + "Total hours should be 7 (3 + 2.5 + 1.5) with multiple timesheets.", + ) diff --git a/quality_control_oca_timesheet/views/qc_inspection_view.xml b/quality_control_oca_timesheet/views/qc_inspection_view.xml new file mode 100644 index 000000000..ac382ac3f --- /dev/null +++ b/quality_control_oca_timesheet/views/qc_inspection_view.xml @@ -0,0 +1,51 @@ + + + qc.inspection.form.view.timesheet + qc.inspection + + + + + + + + + + + + + + + + + + + + + + + + + qc.inspection.tree.view.timesheet.inherit + qc.inspection + + + + + + + + +