-
-
Notifications
You must be signed in to change notification settings - Fork 166
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
14 changed files
with
150 additions
and
91 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
11 changes: 11 additions & 0 deletions
11
maintenance_project/migrations/17.0.2.0.0/post-migration.py
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Copyright 2024 Tecnativa - Víctor Martínez | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from openupgradelib import openupgrade | ||
|
||
|
||
@openupgrade.migrate() | ||
def migrate(env, version): | ||
env.ref("maintenance.group_equipment_manager").write( | ||
{"implied_ids": [(3, env.ref("project.group_project_manager").id)]} | ||
) |
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
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
Oops, something went wrong.