Initial commit: OCA Technical packages (595 packages)

This commit is contained in:
Ernad Husremovic 2025-08-29 15:43:03 +02:00
commit 2cc02aac6e
24950 changed files with 2318079 additions and 0 deletions

View file

@ -0,0 +1,3 @@
from . import maintenance_equipment
from . import maintenance_request
from . import project_project

View file

@ -0,0 +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 fields, models
class MaintenanceEquipment(models.Model):
_inherit = "maintenance.equipment"
project_id = fields.Many2one(comodel_name="project.project", ondelete="restrict")
preventive_default_task_id = fields.Many2one(
string="Default Task", comodel_name="project.task"
)
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):
"""
Default project data creation hook
"""
return {"name": self.name}

View file

@ -0,0 +1,33 @@
# Copyright 2019 Solvos Consultoría Informática (<http://www.solvos.es>)
# 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):
res = super().onchange_equipment_id()
if self.equipment_id and self.equipment_id.project_id:
self.project_id = self.equipment_id.project_id
return res

View file

@ -0,0 +1,58 @@
# Copyright 2019 Solvos Consultoría Informática (<http://www.solvos.es>)
# 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