-
-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by pedrobaeza
- Loading branch information
Showing
13 changed files
with
129 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,27 @@ | ||
# Copyright 2019 Solvos Consultoría Informática (<http://www.solvos.es>) | ||
# Copyright 2024 Tecnativa - Víctor Martínez | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
|
||
from odoo import api, fields, models | ||
from odoo import 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 action_create_project(self): | ||
self.ensure_one() | ||
if not self.project_id: | ||
self.project_id = self.env["project.project"].create( | ||
self._prepare_project_from_equipment_values() | ||
) | ||
|
||
def _prepare_project_from_equipment_values(self, values): | ||
def _prepare_project_from_equipment_values(self): | ||
""" | ||
Default project data creation hook | ||
""" | ||
return {"name": values.get("name")} | ||
return {"name": self.name} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
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 a project to an equipment. You can link an existing project or create a new one (with the Create project button) after creating the equipment. | ||
- 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. |
6 changes: 0 additions & 6 deletions
6
maintenance_project/security/maintenance_project_security.xml
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.