diff --git a/maintenance_request_checklist/README.rst b/maintenance_request_checklist/README.rst new file mode 100644 index 000000000..e6c1d7b54 --- /dev/null +++ b/maintenance_request_checklist/README.rst @@ -0,0 +1,103 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +============================= +Maintenance Request Checklist +============================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:d41cc5037faf89d7baaec2a6dc08d7c838e087c9d2a73210fcc68ac08725ac63 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/license-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/16.0/maintenance_request_checklist + :alt: OCA/maintenance +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/maintenance-16-0/maintenance-16-0-maintenance_request_checklist + :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/maintenance&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module adds an execution checklist to maintenance requests, allowing +technicians to confirm each step of the maintenance procedure. + +A **Checklist** tab is added to the maintenance request form with an ordered +list of steps. For each step the technician can: + +- Mark it as **Done** with a checkbox. +- Add optional **Notes** about the execution. + +When a step is marked as done, the system automatically records **who** confirmed +it and **when**, providing a traceable audit trail suitable for ISO 9000 and +similar quality management requirements. + +A progress counter (steps done / total steps) is displayed at the top of the +tab for quick visibility of the request completion status. + +**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 to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Escodoo + +Contributors +~~~~~~~~~~~~ + +* Marcel Savegnago +* Cristiano Mafra Junior + +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-CristianoMafraJunior, marcelsavegnago| image:: https://github.com/CristianoMafraJunior, marcelsavegnago.png?size=40px + :target: https://github.com/CristianoMafraJunior, marcelsavegnago + :alt: CristianoMafraJunior, marcelsavegnago + +Current `maintainer `__: + +|maintainer-CristianoMafraJunior, marcelsavegnago| + +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_request_checklist/__init__.py b/maintenance_request_checklist/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/maintenance_request_checklist/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/maintenance_request_checklist/__manifest__.py b/maintenance_request_checklist/__manifest__.py new file mode 100644 index 000000000..2a83c2ba8 --- /dev/null +++ b/maintenance_request_checklist/__manifest__.py @@ -0,0 +1,20 @@ +# Copyright 2026 - TODAY, Cristiano Mafra Junior +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +{ + "name": "Maintenance Request Checklist", + "summary": "Adds an execution checklist to maintenance requests", + "version": "16.0.1.0.0", + "author": "Escodoo, Odoo Community Association (OCA)", + "license": "AGPL-3", + "category": "Maintenance", + "website": "https://github.com/OCA/maintenance", + "depends": ["base_maintenance"], + "maintainers": [ + "CristianoMafraJunior, marcelsavegnago", + ], + "data": [ + "security/ir.model.access.csv", + "views/maintenance_request_views.xml", + ], + "installable": True, +} diff --git a/maintenance_request_checklist/models/__init__.py b/maintenance_request_checklist/models/__init__.py new file mode 100644 index 000000000..110d703e0 --- /dev/null +++ b/maintenance_request_checklist/models/__init__.py @@ -0,0 +1,5 @@ +# Copyright 2026 - TODAY, Cristiano Mafra Junior +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import maintenance_request +from . import maintenance_request_checklist_line diff --git a/maintenance_request_checklist/models/maintenance_request.py b/maintenance_request_checklist/models/maintenance_request.py new file mode 100644 index 000000000..a969d80df --- /dev/null +++ b/maintenance_request_checklist/models/maintenance_request.py @@ -0,0 +1,27 @@ +# Copyright 2026 - TODAY, Cristiano Mafra Junior +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class MaintenanceRequest(models.Model): + _inherit = "maintenance.request" + + checklist_ids = fields.One2many( + comodel_name="maintenance.request.checklist.line", + inverse_name="request_id", + string="Checklist", + ) + checklist_total = fields.Integer( + string="Total Steps", compute="_compute_checklist_progress", store=True + ) + checklist_done = fields.Integer( + string="Steps Done", compute="_compute_checklist_progress", store=True + ) + + @api.depends("checklist_ids.is_done") + def _compute_checklist_progress(self): + for rec in self: + lines = rec.checklist_ids + rec.checklist_total = len(lines) + rec.checklist_done = len(lines.filtered("is_done")) diff --git a/maintenance_request_checklist/models/maintenance_request_checklist_line.py b/maintenance_request_checklist/models/maintenance_request_checklist_line.py new file mode 100644 index 000000000..b610d6406 --- /dev/null +++ b/maintenance_request_checklist/models/maintenance_request_checklist_line.py @@ -0,0 +1,37 @@ +# Copyright 2026 - TODAY, Cristiano Mafra Junior +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class MaintenanceRequestChecklistLine(models.Model): + _name = "maintenance.request.checklist.line" + _description = "Maintenance Request Checklist Line" + _order = "sequence, id" + + request_id = fields.Many2one( + comodel_name="maintenance.request", + string="Maintenance Request", + required=True, + ondelete="cascade", + index=True, + ) + sequence = fields.Integer(default=10) + name = fields.Char(string="Step", required=True) + is_done = fields.Boolean(string="Done") + done_by = fields.Many2one( + comodel_name="res.users", + readonly=True, + ) + done_date = fields.Datetime(string="Done On", readonly=True) + notes = fields.Char() + + def write(self, vals): + if "is_done" in vals: + if vals["is_done"]: + vals.setdefault("done_by", self.env.uid) + vals.setdefault("done_date", fields.Datetime.now()) + else: + vals["done_by"] = False + vals["done_date"] = False + return super().write(vals) diff --git a/maintenance_request_checklist/readme/CONTRIBUTORS.rst b/maintenance_request_checklist/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..ffae23c8c --- /dev/null +++ b/maintenance_request_checklist/readme/CONTRIBUTORS.rst @@ -0,0 +1,2 @@ +* Marcel Savegnago +* Cristiano Mafra Junior diff --git a/maintenance_request_checklist/readme/DESCRIPTION.rst b/maintenance_request_checklist/readme/DESCRIPTION.rst new file mode 100644 index 000000000..9b968cfd6 --- /dev/null +++ b/maintenance_request_checklist/readme/DESCRIPTION.rst @@ -0,0 +1,15 @@ +This module adds an execution checklist to maintenance requests, allowing +technicians to confirm each step of the maintenance procedure. + +A **Checklist** tab is added to the maintenance request form with an ordered +list of steps. For each step the technician can: + +- Mark it as **Done** with a checkbox. +- Add optional **Notes** about the execution. + +When a step is marked as done, the system automatically records **who** confirmed +it and **when**, providing a traceable audit trail suitable for ISO 9000 and +similar quality management requirements. + +A progress counter (steps done / total steps) is displayed at the top of the +tab for quick visibility of the request completion status. diff --git a/maintenance_request_checklist/security/ir.model.access.csv b/maintenance_request_checklist/security/ir.model.access.csv new file mode 100644 index 000000000..c1a2bf05a --- /dev/null +++ b/maintenance_request_checklist/security/ir.model.access.csv @@ -0,0 +1,3 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_checklist_line_user,access_checklist_line_user,model_maintenance_request_checklist_line,base.group_user,1,1,1,0 +access_checklist_line_manager,access_checklist_line_manager,model_maintenance_request_checklist_line,maintenance.group_equipment_manager,1,1,1,1 diff --git a/maintenance_request_checklist/static/description/icon.png b/maintenance_request_checklist/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/maintenance_request_checklist/static/description/icon.png differ diff --git a/maintenance_request_checklist/static/description/index.html b/maintenance_request_checklist/static/description/index.html new file mode 100644 index 000000000..89efb2ec5 --- /dev/null +++ b/maintenance_request_checklist/static/description/index.html @@ -0,0 +1,444 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

Maintenance Request Checklist

+ +

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

+

This module adds an execution checklist to maintenance requests, allowing +technicians to confirm each step of the maintenance procedure.

+

A Checklist tab is added to the maintenance request form with an ordered +list of steps. For each step the technician can:

+
    +
  • Mark it as Done with a checkbox.
  • +
  • Add optional Notes about the execution.
  • +
+

When a step is marked as done, the system automatically records who confirmed +it and when, providing a traceable audit trail suitable for ISO 9000 and +similar quality management requirements.

+

A progress counter (steps done / total steps) is displayed at the top of the +tab for quick visibility of the request completion status.

+

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 to smash it by providing a detailed and welcomed +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Escodoo
  • +
+
+
+

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.

+

Current maintainer:

+

CristianoMafraJunior, marcelsavegnago

+

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_request_checklist/tests/__init__.py b/maintenance_request_checklist/tests/__init__.py new file mode 100644 index 000000000..24b88cc18 --- /dev/null +++ b/maintenance_request_checklist/tests/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2026 - TODAY, Cristiano Mafra Junior +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import test_maintenance_request_checklist diff --git a/maintenance_request_checklist/tests/test_maintenance_request_checklist.py b/maintenance_request_checklist/tests/test_maintenance_request_checklist.py new file mode 100644 index 000000000..8c4c41e85 --- /dev/null +++ b/maintenance_request_checklist/tests/test_maintenance_request_checklist.py @@ -0,0 +1,122 @@ +# Copyright 2026 - TODAY, Cristiano Mafra Junior +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields +from odoo.tests.common import TransactionCase + + +class TestMaintenanceRequestChecklist(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.env = cls.env( + context=dict( + cls.env.context, + tracking_disable=True, + mail_create_nolog=True, + mail_create_nosubscribe=True, + mail_notrack=True, + no_reset_password=True, + ) + ) + cls.ChecklistLine = cls.env["maintenance.request.checklist.line"] + cls.request = cls.env["maintenance.request"].create({"name": "Test Request"}) + cls.line_vals = [ + {"name": "Check oil level", "sequence": 10}, + {"name": "Inspect belts", "sequence": 20}, + {"name": "Test brakes", "sequence": 30}, + ] + + def _create_lines(self, vals_list=None): + vals = vals_list or self.line_vals + return self.ChecklistLine.create( + [dict(v, request_id=self.request.id) for v in vals] + ) + + def test_checklist_line_creation(self): + lines = self._create_lines() + self.assertEqual(len(lines), 3) + self.assertEqual(lines.mapped("request_id"), self.request) + for line in lines: + self.assertFalse(line.is_done) + self.assertFalse(line.done_by) + self.assertFalse(line.done_date) + + def test_mark_done_sets_audit_fields(self): + line = self._create_lines([{"name": "Check oil level", "sequence": 10}]) + before = fields.Datetime.now() + line.write({"is_done": True}) + after = fields.Datetime.now() + + self.assertTrue(line.is_done) + self.assertEqual(line.done_by, self.env.user) + self.assertTrue(line.done_date) + self.assertGreaterEqual(line.done_date, before) + self.assertLessEqual(line.done_date, after) + + def test_unmark_done_clears_audit_fields(self): + line = self._create_lines([{"name": "Check oil level", "sequence": 10}]) + line.write({"is_done": True}) + self.assertTrue(line.is_done) + + line.write({"is_done": False}) + self.assertFalse(line.is_done) + self.assertFalse(line.done_by) + self.assertFalse(line.done_date) + + def test_done_by_not_overwritten_if_already_set(self): + other_user = self.env["res.users"].create( + { + "name": "Mechanic", + "login": "mechanic_test", + "email": "mechanic@test.com", + } + ) + line = self._create_lines([{"name": "Check oil level", "sequence": 10}]) + line.write({"is_done": True, "done_by": other_user.id}) + # done_by explicitly passed should be respected (setdefault behaviour) + self.assertEqual(line.done_by, other_user) + + def test_checklist_progress_counters(self): + lines = self._create_lines() + self.request.invalidate_recordset() + self.assertEqual(self.request.checklist_total, 3) + self.assertEqual(self.request.checklist_done, 0) + + lines[0].write({"is_done": True}) + self.request.invalidate_recordset() + self.assertEqual(self.request.checklist_done, 1) + + lines[1].write({"is_done": True}) + self.request.invalidate_recordset() + self.assertEqual(self.request.checklist_done, 2) + + lines[0].write({"is_done": False}) + self.request.invalidate_recordset() + self.assertEqual(self.request.checklist_done, 1) + + def test_checklist_total_with_no_lines(self): + request = self.env["maintenance.request"].create({"name": "Empty Request"}) + self.assertEqual(request.checklist_total, 0) + self.assertEqual(request.checklist_done, 0) + + def test_sequence_ordering(self): + lines = self.ChecklistLine.create( + [ + {"request_id": self.request.id, "name": "Step C", "sequence": 30}, + {"request_id": self.request.id, "name": "Step A", "sequence": 10}, + {"request_id": self.request.id, "name": "Step B", "sequence": 20}, + ] + ) + ordered = self.ChecklistLine.search( + [("id", "in", lines.ids)], order="sequence asc" + ) + self.assertEqual(ordered.mapped("name"), ["Step A", "Step B", "Step C"]) + + def test_line_cascade_delete(self): + lines = self._create_lines() + request = lines[0].request_id + line_ids = lines.ids + request.unlink() + remaining = self.ChecklistLine.search([("id", "in", line_ids)]) + self.assertFalse(remaining) diff --git a/maintenance_request_checklist/views/maintenance_request_views.xml b/maintenance_request_checklist/views/maintenance_request_views.xml new file mode 100644 index 000000000..c1091e277 --- /dev/null +++ b/maintenance_request_checklist/views/maintenance_request_views.xml @@ -0,0 +1,36 @@ + + + + + equipment.request.form.checklist + maintenance.request + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/setup/maintenance_request_checklist/odoo/addons/maintenance_request_checklist b/setup/maintenance_request_checklist/odoo/addons/maintenance_request_checklist new file mode 120000 index 000000000..02b72260b --- /dev/null +++ b/setup/maintenance_request_checklist/odoo/addons/maintenance_request_checklist @@ -0,0 +1 @@ +../../../../maintenance_request_checklist \ No newline at end of file diff --git a/setup/maintenance_request_checklist/setup.py b/setup/maintenance_request_checklist/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/maintenance_request_checklist/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)