diff --git a/maintenance_project/README.rst b/maintenance_project/README.rst new file mode 100644 index 000000000..48b00297f --- /dev/null +++ b/maintenance_project/README.rst @@ -0,0 +1,86 @@ +==================== +Maintenance Projects +==================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:3944d0553cc33d2901bb5c8bda9160ef108a2a8f193aa4b57ae169600185a2f5 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/17.0/maintenance_project + :alt: OCA/maintenance +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/maintenance-17-0/maintenance-17-0-maintenance_project + :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=17.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module extends the functionality of Odoo Maintenance module adding +this features: + +- Adds a project to an equipment. The project can be automatically + created from the equipment definition. +- Adds project and task to a maintenance request. The default project + for a request will be the equipment one, including the preventive + requests periodically created. + +This is is a technical addon to allow timesheet assignment to a +maintenance 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 to smash 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_project/__init__.py b/maintenance_project/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/maintenance_project/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/maintenance_project/__manifest__.py b/maintenance_project/__manifest__.py new file mode 100644 index 000000000..93e37c578 --- /dev/null +++ b/maintenance_project/__manifest__.py @@ -0,0 +1,21 @@ +# Copyright 2019 Solvos Consultoría Informática () +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html +{ + "name": "Maintenance Projects", + "summary": "Adds projects to maintenance equipments and requests", + "version": "17.0.1.0.0", + "author": "Odoo Community Association (OCA), Solvos", + "license": "AGPL-3", + "category": "Maintenance", + "website": "https://github.com/OCA/maintenance", + "depends": ["base_maintenance", "project"], + "data": [ + "security/maintenance_project_security.xml", + "views/maintenance_equipment_views.xml", + "views/maintenance_request_views.xml", + "views/project_project_views.xml", + "report/maintenance_request_report.xml", + ], + "demo": ["demo/demo_maintenance_project.xml"], + "installable": True, +} diff --git a/maintenance_project/demo/demo_maintenance_project.xml b/maintenance_project/demo/demo_maintenance_project.xml new file mode 100644 index 000000000..df3893b7c --- /dev/null +++ b/maintenance_project/demo/demo_maintenance_project.xml @@ -0,0 +1,56 @@ + + + General equipment project + + + + + + General task + + + + + Default preventive task + + + Generic Monitor + + + + + S/N 1 + MODEL1 + + + + + Generic Monitor with preventive + + + + + + S/N 2 + MODEL2 + + + + + + Generic Computer with own project + + + + + S/N 3 + MODEL3 + + + diff --git a/maintenance_project/i18n/es.po b/maintenance_project/i18n/es.po new file mode 100644 index 000000000..08d3e7726 --- /dev/null +++ b/maintenance_project/i18n/es.po @@ -0,0 +1,136 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * maintenance_project +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2019-09-18 17:04+0000\n" +"PO-Revision-Date: 2023-07-22 23:09+0000\n" +"Last-Translator: Ivorra78 \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 4.17\n" + +#. module: maintenance_project +#: model_terms:ir.ui.view,arch_db:maintenance_project.view_project_kanban +msgid "Equipments" +msgstr "Equipos" + +#. module: maintenance_project +#: model_terms:ir.ui.view,arch_db:maintenance_project.view_project_kanban +msgid "Requests" +msgstr "Peticiones" + +#. module: maintenance_project +#: model_terms:ir.ui.view,arch_db:maintenance_project.report_maintenance_request_document +msgid "Project:" +msgstr "Proyecto:" + +#. module: maintenance_project +#: model_terms:ir.ui.view,arch_db:maintenance_project.report_maintenance_request_document +msgid "Task:" +msgstr "Tarea:" + +#. module: maintenance_project +#: model:ir.model.fields,field_description:maintenance_project.field_maintenance_equipment__create_project_from_equipment +msgid "Create Project From Equipment" +msgstr "Crear proyecto a partir del equipo" + +#. module: maintenance_project +#: model:ir.model.fields,field_description:maintenance_project.field_maintenance_equipment__preventive_default_task_id +msgid "Default Task" +msgstr "Tarea por defecto" + +#. module: maintenance_project +#: model:ir.model.fields,field_description:maintenance_project.field_project_project__equipment_count +msgid "Equipment Count" +msgstr "N??mero de equipos" + +#. module: maintenance_project +#: model:ir.model.fields,field_description:maintenance_project.field_project_project__equipment_ids +#: model_terms:ir.ui.view,arch_db:maintenance_project.edit_project +msgid "Equipments" +msgstr "Equipos" + +#. module: maintenance_project +#: model:project.project,name:maintenance_project.project_project_1 +msgid "General equipment project" +msgstr "Proyecto de equipamiento general" + +#. module: maintenance_project +#: model:maintenance.equipment,name:maintenance_project.equipment_3 +msgid "Generic Computer with own project" +msgstr "Ordenador gen??rico con su propio proyecto" + +#. module: maintenance_project +#: model:maintenance.equipment,name:maintenance_project.equipment_1 +msgid "Generic Monitor" +msgstr "Monitor gen??rico" + +#. module: maintenance_project +#: model:maintenance.equipment,name:maintenance_project.equipment_2 +msgid "Generic Monitor with preventive" +msgstr "Monitor gen??rico con preventivo" + +#. module: maintenance_project +#: model:ir.model,name:maintenance_project.model_maintenance_equipment +msgid "Maintenance Equipment" +msgstr "Equipo" + +#. module: maintenance_project +#: model:ir.model,name:maintenance_project.model_maintenance_request +msgid "Maintenance Request" +msgstr "Petici??n de mantenimiento" + +#. module: maintenance_project +#: model:ir.model.fields,field_description:maintenance_project.field_project_project__maintenance_request_count +msgid "Maintenance Request Count" +msgstr "N??mero de peticiones de mantenimiento" + +#. module: maintenance_project +#: model:ir.model.fields,field_description:maintenance_project.field_project_project__maintenance_request_ids +msgid "Maintenance Requests" +msgstr "Peticiones de mantenimiento" + +#. module: maintenance_project +#: model:ir.model,name:maintenance_project.model_project_project +#: model:ir.model.fields,field_description:maintenance_project.field_maintenance_equipment__project_id +#: model:ir.model.fields,field_description:maintenance_project.field_maintenance_request__project_id +msgid "Project" +msgstr "Proyecto" + +#. module: maintenance_project +#: model_terms:ir.ui.view,arch_db:maintenance_project.hr_equipment_request_view_kanban +#: model_terms:ir.ui.view,arch_db:maintenance_project.hr_equipment_view_kanban +msgid "Project:" +msgstr "Proyecto:" + +#. module: maintenance_project +#: model_terms:ir.ui.view,arch_db:maintenance_project.edit_project +msgid "Requests" +msgstr "Peticiones" + +#. module: maintenance_project +#: model:ir.model.fields,field_description:maintenance_project.field_maintenance_request__task_id +msgid "Task" +msgstr "Tarea" + +#. module: maintenance_project +#: model:project.project,label_tasks:maintenance_project.project_project_1 +msgid "Tasks" +msgstr "Tareas" + +#~ msgid "Display Name" +#~ msgstr "Nombre a mostrar" + +#~ msgid "ID" +#~ msgstr "ID" + +#~ msgid "Last Modified on" +#~ msgstr "Última modificación en" diff --git a/maintenance_project/i18n/it.po b/maintenance_project/i18n/it.po new file mode 100644 index 000000000..73e12efc8 --- /dev/null +++ b/maintenance_project/i18n/it.po @@ -0,0 +1,135 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * maintenance_project +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-11-12 17:41+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.17\n" + +#. module: maintenance_project +#: model_terms:ir.ui.view,arch_db:maintenance_project.view_project_kanban +msgid "Equipments" +msgstr "Attrezzature" + +#. module: maintenance_project +#: model_terms:ir.ui.view,arch_db:maintenance_project.view_project_kanban +msgid "Requests" +msgstr "Richieste" + +#. module: maintenance_project +#: model_terms:ir.ui.view,arch_db:maintenance_project.report_maintenance_request_document +msgid "Project:" +msgstr "Progetto:" + +#. module: maintenance_project +#: model_terms:ir.ui.view,arch_db:maintenance_project.report_maintenance_request_document +msgid "Task:" +msgstr "Lavoro:" + +#. module: maintenance_project +#: model:ir.model.fields,field_description:maintenance_project.field_maintenance_equipment__create_project_from_equipment +msgid "Create Project From Equipment" +msgstr "Crea un progetto dall'attrezzatura" + +#. module: maintenance_project +#: model:ir.model.fields,field_description:maintenance_project.field_maintenance_equipment__preventive_default_task_id +msgid "Default Task" +msgstr "Lavoro predefinito" + +#. module: maintenance_project +#: model:ir.model.fields,field_description:maintenance_project.field_project_project__equipment_count +msgid "Equipment Count" +msgstr "Conteggio attrezzature" + +#. module: maintenance_project +#: model:ir.model.fields,field_description:maintenance_project.field_project_project__equipment_ids +#: model_terms:ir.ui.view,arch_db:maintenance_project.edit_project +msgid "Equipments" +msgstr "Attrezzature" + +#. module: maintenance_project +#: model:project.project,name:maintenance_project.project_project_1 +msgid "General equipment project" +msgstr "Progetto attrezzatura generica" + +#. module: maintenance_project +#: model:maintenance.equipment,name:maintenance_project.equipment_3 +msgid "Generic Computer with own project" +msgstr "Computer generico con progetto proprio" + +#. module: maintenance_project +#: model:maintenance.equipment,name:maintenance_project.equipment_1 +msgid "Generic Monitor" +msgstr "Monitor generico" + +#. module: maintenance_project +#: model:maintenance.equipment,name:maintenance_project.equipment_2 +msgid "Generic Monitor with preventive" +msgstr "Monitor generico con preventiva" + +#. module: maintenance_project +#: model:ir.model,name:maintenance_project.model_maintenance_equipment +msgid "Maintenance Equipment" +msgstr "Attrezzatura manutenzione" + +#. module: maintenance_project +#: model:ir.model,name:maintenance_project.model_maintenance_request +msgid "Maintenance Request" +msgstr "Richiesta manutenzione" + +#. module: maintenance_project +#: model:ir.model.fields,field_description:maintenance_project.field_project_project__maintenance_request_count +msgid "Maintenance Request Count" +msgstr "Conta richiesta manutenzione" + +#. module: maintenance_project +#: model:ir.model.fields,field_description:maintenance_project.field_project_project__maintenance_request_ids +msgid "Maintenance Requests" +msgstr "Richieste manutenzione" + +#. module: maintenance_project +#: model:ir.model,name:maintenance_project.model_project_project +#: model:ir.model.fields,field_description:maintenance_project.field_maintenance_equipment__project_id +#: model:ir.model.fields,field_description:maintenance_project.field_maintenance_request__project_id +msgid "Project" +msgstr "Progetto" + +#. module: maintenance_project +#: model_terms:ir.ui.view,arch_db:maintenance_project.hr_equipment_request_view_kanban +#: model_terms:ir.ui.view,arch_db:maintenance_project.hr_equipment_view_kanban +msgid "Project:" +msgstr "Progetto:" + +#. module: maintenance_project +#: model_terms:ir.ui.view,arch_db:maintenance_project.edit_project +msgid "Requests" +msgstr "Richieste" + +#. module: maintenance_project +#: model:ir.model.fields,field_description:maintenance_project.field_maintenance_request__task_id +msgid "Task" +msgstr "Lavoro" + +#. module: maintenance_project +#: model:project.project,label_tasks:maintenance_project.project_project_1 +msgid "Tasks" +msgstr "Lavori" + +#~ msgid "Display Name" +#~ msgstr "Nome visualizzato" + +#~ msgid "ID" +#~ msgstr "ID" + +#~ msgid "Last Modified on" +#~ msgstr "Ultima modifica il" diff --git a/maintenance_project/i18n/maintenance_project.pot b/maintenance_project/i18n/maintenance_project.pot new file mode 100644 index 000000000..ea233f192 --- /dev/null +++ b/maintenance_project/i18n/maintenance_project.pot @@ -0,0 +1,123 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * maintenance_project +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.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_project +#: model_terms:ir.ui.view,arch_db:maintenance_project.view_project_kanban +msgid "Equipments" +msgstr "" + +#. module: maintenance_project +#: model_terms:ir.ui.view,arch_db:maintenance_project.view_project_kanban +msgid "Requests" +msgstr "" + +#. module: maintenance_project +#: model_terms:ir.ui.view,arch_db:maintenance_project.report_maintenance_request_document +msgid "Project:" +msgstr "" + +#. module: maintenance_project +#: model_terms:ir.ui.view,arch_db:maintenance_project.report_maintenance_request_document +msgid "Task:" +msgstr "" + +#. module: maintenance_project +#: model:ir.model.fields,field_description:maintenance_project.field_maintenance_equipment__create_project_from_equipment +msgid "Create Project From Equipment" +msgstr "" + +#. module: maintenance_project +#: model:ir.model.fields,field_description:maintenance_project.field_maintenance_equipment__preventive_default_task_id +msgid "Default Task" +msgstr "" + +#. module: maintenance_project +#: model:ir.model.fields,field_description:maintenance_project.field_project_project__equipment_count +msgid "Equipment Count" +msgstr "" + +#. module: maintenance_project +#: model:ir.model.fields,field_description:maintenance_project.field_project_project__equipment_ids +#: model_terms:ir.ui.view,arch_db:maintenance_project.edit_project +msgid "Equipments" +msgstr "" + +#. module: maintenance_project +#: model:project.project,name:maintenance_project.project_project_1 +msgid "General equipment project" +msgstr "" + +#. module: maintenance_project +#: model:maintenance.equipment,name:maintenance_project.equipment_3 +msgid "Generic Computer with own project" +msgstr "" + +#. module: maintenance_project +#: model:maintenance.equipment,name:maintenance_project.equipment_1 +msgid "Generic Monitor" +msgstr "" + +#. module: maintenance_project +#: model:maintenance.equipment,name:maintenance_project.equipment_2 +msgid "Generic Monitor with preventive" +msgstr "" + +#. module: maintenance_project +#: model:ir.model,name:maintenance_project.model_maintenance_equipment +msgid "Maintenance Equipment" +msgstr "" + +#. module: maintenance_project +#: model:ir.model,name:maintenance_project.model_maintenance_request +msgid "Maintenance Request" +msgstr "" + +#. module: maintenance_project +#: model:ir.model.fields,field_description:maintenance_project.field_project_project__maintenance_request_count +msgid "Maintenance Request Count" +msgstr "" + +#. module: maintenance_project +#: model:ir.model.fields,field_description:maintenance_project.field_project_project__maintenance_request_ids +msgid "Maintenance Requests" +msgstr "" + +#. module: maintenance_project +#: model:ir.model,name:maintenance_project.model_project_project +#: model:ir.model.fields,field_description:maintenance_project.field_maintenance_equipment__project_id +#: model:ir.model.fields,field_description:maintenance_project.field_maintenance_request__project_id +msgid "Project" +msgstr "" + +#. module: maintenance_project +#: model_terms:ir.ui.view,arch_db:maintenance_project.hr_equipment_request_view_kanban +#: model_terms:ir.ui.view,arch_db:maintenance_project.hr_equipment_view_kanban +msgid "Project:" +msgstr "" + +#. module: maintenance_project +#: model_terms:ir.ui.view,arch_db:maintenance_project.edit_project +msgid "Requests" +msgstr "" + +#. module: maintenance_project +#: model:ir.model.fields,field_description:maintenance_project.field_maintenance_request__task_id +msgid "Task" +msgstr "" + +#. module: maintenance_project +#: model:project.project,label_tasks:maintenance_project.project_project_1 +msgid "Tasks" +msgstr "" diff --git a/maintenance_project/models/__init__.py b/maintenance_project/models/__init__.py new file mode 100644 index 000000000..5348c708d --- /dev/null +++ b/maintenance_project/models/__init__.py @@ -0,0 +1,3 @@ +from . import maintenance_equipment +from . import maintenance_request +from . import project_project diff --git a/maintenance_project/models/maintenance_equipment.py b/maintenance_project/models/maintenance_equipment.py new file mode 100644 index 000000000..27c050118 --- /dev/null +++ b/maintenance_project/models/maintenance_equipment.py @@ -0,0 +1,31 @@ +# Copyright 2019 Solvos Consultoría Informática () +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from odoo import api, fields, models + + +class MaintenanceEquipment(models.Model): + _inherit = "maintenance.equipment" + + project_id = fields.Many2one(comodel_name="project.project", ondelete="restrict") + create_project_from_equipment = fields.Boolean(default=True) + preventive_default_task_id = fields.Many2one( + string="Default Task", comodel_name="project.task" + ) + + @api.model_create_multi + def create(self, vals_list): + project_obj = self.env["project.project"] + for values in vals_list: + if values.get("create_project_from_equipment"): + new_project = project_obj.create( + self._prepare_project_from_equipment_values(values) + ) + values["project_id"] = new_project.id + return super().create(vals_list) + + def _prepare_project_from_equipment_values(self, values): + """ + Default project data creation hook + """ + return {"name": values.get("name")} diff --git a/maintenance_project/models/maintenance_request.py b/maintenance_project/models/maintenance_request.py new file mode 100644 index 000000000..63a823fb6 --- /dev/null +++ b/maintenance_project/models/maintenance_request.py @@ -0,0 +1,31 @@ +# Copyright 2019 Solvos Consultoría Informática () +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from odoo import api, fields, models + + +class MaintenanceRequest(models.Model): + _inherit = "maintenance.request" + + project_id = fields.Many2one(comodel_name="project.project") + task_id = fields.Many2one(comodel_name="project.task") + + @api.model_create_multi + def create(self, vals_list): + """ + We ensure for appropiate project and task for new requests, + specially the automatically generated ones + """ + newreqs = super().create(vals_list) + for newreq in newreqs: + if not newreq.project_id and newreq.equipment_id: + newreq.project_id = newreq.equipment_id.project_id + if not newreq.task_id and newreq.maintenance_type == "preventive": + newreq.task_id = newreq.equipment_id.preventive_default_task_id + + return newreqs + + @api.onchange("equipment_id") + def onchange_equipment_id(self): + if self.equipment_id and self.equipment_id.project_id: + self.project_id = self.equipment_id.project_id diff --git a/maintenance_project/models/project_project.py b/maintenance_project/models/project_project.py new file mode 100644 index 000000000..00394deb8 --- /dev/null +++ b/maintenance_project/models/project_project.py @@ -0,0 +1,58 @@ +# Copyright 2019 Solvos Consultoría Informática () +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from odoo import api, fields, models + + +class ProjectProject(models.Model): + _inherit = "project.project" + + equipment_count = fields.Integer(compute="_compute_equipment_count") + equipment_ids = fields.One2many( + "maintenance.equipment", "project_id", string="Equipments" + ) + maintenance_request_count = fields.Integer( + compute="_compute_maintenance_request_count" + ) + maintenance_request_ids = fields.One2many( + "maintenance.request", "project_id", string="Maintenance Requests" + ) + + @api.depends("equipment_ids") + def _compute_equipment_count(self): + for project in self: + project.equipment_count = len(project.equipment_ids) + + def action_view_equipment_ids(self): + """ + Access to the current equipments for this project + """ + self.ensure_one() + action = self.env["ir.actions.actions"]._for_xml_id( + "maintenance.hr_equipment_action" + ) + action["domain"] = [("project_id", "=", self.id)] + action["context"] = { + "default_project_id": self.id, + "default_create_project_from_equipment": False, + } + return action + + @api.depends("maintenance_request_ids") + def _compute_maintenance_request_count(self): + for project in self: + project.maintenance_request_count = len( + project.maintenance_request_ids.filtered(lambda x: not x.stage_id.done) + ) + + def action_view_maintenance_request_ids(self): + """ + Access to the undone maintenance requests for this project + """ + self.ensure_one() + action = self.env["ir.actions.actions"]._for_xml_id( + "maintenance.hr_equipment_request_action" + ) + action["domain"] = [("project_id", "=", self.id), ("stage_id.done", "=", False)] + action["context"] = {"default_project_id": self.id} + return action diff --git a/maintenance_project/pyproject.toml b/maintenance_project/pyproject.toml new file mode 100644 index 000000000..4231d0ccc --- /dev/null +++ b/maintenance_project/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/maintenance_project/readme/CONTRIBUTORS.md b/maintenance_project/readme/CONTRIBUTORS.md new file mode 100644 index 000000000..a018cb721 --- /dev/null +++ b/maintenance_project/readme/CONTRIBUTORS.md @@ -0,0 +1 @@ +- David Alonso \<\> diff --git a/maintenance_project/readme/DESCRIPTION.md b/maintenance_project/readme/DESCRIPTION.md new file mode 100644 index 000000000..0241f0a55 --- /dev/null +++ b/maintenance_project/readme/DESCRIPTION.md @@ -0,0 +1,11 @@ +This module extends the functionality of Odoo Maintenance module adding +this features: + +- Adds a project to an equipment. The project can be automatically + created from the equipment definition. +- Adds project and task to a maintenance request. The default project + for a request will be the equipment one, including the preventive + requests periodically created. + +This is is a technical addon to allow timesheet assignment to a +maintenance request. diff --git a/maintenance_project/report/maintenance_request_report.xml b/maintenance_project/report/maintenance_request_report.xml new file mode 100644 index 000000000..630851251 --- /dev/null +++ b/maintenance_project/report/maintenance_request_report.xml @@ -0,0 +1,20 @@ + + + + diff --git a/maintenance_project/security/maintenance_project_security.xml b/maintenance_project/security/maintenance_project_security.xml new file mode 100644 index 000000000..14b6f309a --- /dev/null +++ b/maintenance_project/security/maintenance_project_security.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/maintenance_project/static/description/icon.png b/maintenance_project/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/maintenance_project/static/description/icon.png differ diff --git a/maintenance_project/static/description/index.html b/maintenance_project/static/description/index.html new file mode 100644 index 000000000..1285901cc --- /dev/null +++ b/maintenance_project/static/description/index.html @@ -0,0 +1,430 @@ + + + + + +Maintenance Projects + + + +
+

Maintenance Projects

+ + +

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

+

This module extends the functionality of Odoo Maintenance module adding +this features:

+
    +
  • Adds a project to an equipment. The project can be automatically +created from the equipment definition.
  • +
  • Adds project and task to a maintenance request. The default project +for a request will be the equipment one, including the preventive +requests periodically created.
  • +
+

This is is a technical addon to allow timesheet assignment to a +maintenance 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 to smash 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_project/tests/__init__.py b/maintenance_project/tests/__init__.py new file mode 100644 index 000000000..8b261cdfa --- /dev/null +++ b/maintenance_project/tests/__init__.py @@ -0,0 +1 @@ +from . import test_maintenance_project diff --git a/maintenance_project/tests/test_maintenance_project.py b/maintenance_project/tests/test_maintenance_project.py new file mode 100644 index 000000000..82ff17de4 --- /dev/null +++ b/maintenance_project/tests/test_maintenance_project.py @@ -0,0 +1,106 @@ +# 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 + + +class TestMaintenanceProject(test_common.TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + + cls.project1 = cls.env["project.project"].create({"name": "My project"}) + cls.project_demo1 = cls.env.ref("maintenance_project.project_project_1") + + cls.equipment1 = cls.env["maintenance.equipment"].create( + { + "name": "My equipment", + "create_project_from_equipment": True, + "maintenance_team_id": cls.env.ref( + "maintenance.equipment_team_metrology" + ).id, + } + ) + cls.equipment2 = cls.env["maintenance.equipment"].create( + { + "name": "My equipment without project", + "create_project_from_equipment": False, + } + ) + cls.equipment3 = cls.env["maintenance.equipment"].create( + { + "name": "My equipment with related project", + "create_project_from_equipment": False, + "project_id": cls.project1.id, + } + ) + + cls.equipment_demo1 = cls.env.ref("maintenance_project.equipment_1") + cls.equipment_demo2 = cls.env.ref("maintenance_project.equipment_2") + cls.equipment_demo3 = cls.env.ref("maintenance_project.equipment_3") + + def test_maintenance_equipment_project(self): + self.assertEqual(self.equipment1.name, self.equipment1.project_id.name) + self.assertFalse(self.equipment2.project_id) + self.assertEqual(self.equipment3.project_id, self.project1) + self.assertEqual( + self.equipment_demo3.name, self.equipment_demo3.project_id.name + ) + + def test_project_equipment_count(self): + self.assertEqual(self.project1.equipment_count, 1) + self.assertEqual(self.equipment1.project_id.equipment_count, 1) + self.assertEqual(self.project_demo1.equipment_count, 2) + self.assertEqual(self.equipment_demo3.project_id.equipment_count, 1) + + def test_request_onchange_equipment(self): + req1 = self.env["maintenance.request"].new({"name": "My test request #1"}) + self.assertFalse(req1.project_id) + req1.equipment_id = self.equipment1 + req1.onchange_equipment_id() + self.assertEqual(req1.project_id, self.equipment1.project_id) + + req2 = self.env["maintenance.request"].new({"name": "My test request #2"}) + req2.equipment_id = self.equipment2 + req2.onchange_equipment_id() + self.assertFalse(req2.project_id) + + def test_generate_requests(self): + req_name = "My new recurring test request" + req = self.env["maintenance.request"].create( + { + "name": req_name, + "maintenance_type": "preventive", + "duration": 1.0, + "recurring_maintenance": True, + "repeat_interval": 1, + "repeat_unit": "month", + "repeat_type": "forever", + } + ) + req.equipment_id = self.equipment1 + req.onchange_equipment_id() + req.description = "Request done!" + + request_obj = self.env["maintenance.request"] + domain = [ + ("name", "=", req_name), + ("equipment_id", "=", self.equipment1.id), + ("project_id", "=", self.equipment1.project_id.id), + ] + my_requests = request_obj.search(domain) + self.assertEqual(len(my_requests), 1) + + req.stage_id = self.env.ref("maintenance.stage_3") + my_requests = request_obj.search(domain) + self.assertEqual(len(my_requests), 2) + + def test_action_views(self): + act1 = self.project1.action_view_equipment_ids() + self.assertEqual(act1["domain"][0][2], self.project1.id) + self.assertEqual(act1["context"]["default_project_id"], self.project1.id) + self.assertFalse(act1["context"]["default_create_project_from_equipment"]) + + act2 = self.project1.action_view_maintenance_request_ids() + self.assertEqual(act2["domain"][0][2], self.project1.id) + self.assertEqual(act2["context"]["default_project_id"], self.project1.id) diff --git a/maintenance_project/views/maintenance_equipment_views.xml b/maintenance_project/views/maintenance_equipment_views.xml new file mode 100644 index 000000000..28e14b157 --- /dev/null +++ b/maintenance_project/views/maintenance_equipment_views.xml @@ -0,0 +1,57 @@ + + + + maintenance.equipment + + + + + + + + + maintenance.equipment + + + + + + + + + maintenance.equipment + + + + + + +
+ Project: +
+
+
+
+ + maintenance.equipment + + + + + + + + + + + + + +
diff --git a/maintenance_project/views/maintenance_request_views.xml b/maintenance_project/views/maintenance_request_views.xml new file mode 100644 index 000000000..75f2890ed --- /dev/null +++ b/maintenance_project/views/maintenance_request_views.xml @@ -0,0 +1,49 @@ + + + + maintenance.request + + + + + + + + + maintenance.request + + + + + + + + + maintenance.request + + + + + + +
+ Project: +
+
+
+
+ + maintenance.request + + + + + + + + +
diff --git a/maintenance_project/views/project_project_views.xml b/maintenance_project/views/project_project_views.xml new file mode 100644 index 000000000..e960b9115 --- /dev/null +++ b/maintenance_project/views/project_project_views.xml @@ -0,0 +1,71 @@ + + + + project.project + + + + + + + + +
+ + + + Equipments +
+
+ +
+ + + + Requests +
+
+
+
+
+ + project.project + + + + + + + + +