mirror of
https://github.com/bringout/oca-technical.git
synced 2026-04-19 13:52:02 +02:00
Initial commit: OCA Technical packages (595 packages)
This commit is contained in:
commit
2cc02aac6e
24950 changed files with 2318079 additions and 0 deletions
|
|
@ -0,0 +1,2 @@
|
|||
from . import maintenance
|
||||
from . import maintenance_planned_activity
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
# Copyright 2019-20 ForgeFlow S.L. (https://www.forgeflow.com)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from datetime import timedelta
|
||||
|
||||
from odoo import _, fields, models
|
||||
|
||||
|
||||
class MaintenancePlan(models.Model):
|
||||
_inherit = "maintenance.plan"
|
||||
|
||||
planned_activity_ids = fields.One2many(
|
||||
"maintenance.planned.activity", "maintenance_plan_id", "Planned Activities"
|
||||
)
|
||||
|
||||
|
||||
class MaintenanceEquipment(models.Model):
|
||||
_inherit = "maintenance.equipment"
|
||||
|
||||
def _create_new_request(self, maintenance_plan):
|
||||
new_requests = super()._create_new_request(maintenance_plan)
|
||||
for request in new_requests:
|
||||
for planned_activity in maintenance_plan.planned_activity_ids:
|
||||
# In case mail_activity_team is installed this makes sure
|
||||
# the correct activity team is selected. If that module is
|
||||
# not installed the context does nothing
|
||||
self.env["mail.activity"].with_context(
|
||||
default_res_model="maintenance.request"
|
||||
).create(
|
||||
{
|
||||
"activity_type_id": planned_activity.activity_type_id.id,
|
||||
"note": _(
|
||||
"Activity automatically generated from maintenance plan"
|
||||
),
|
||||
"user_id": planned_activity.user_id.id or self.env.user.id,
|
||||
"res_id": request.id,
|
||||
"res_model_id": self.env.ref(
|
||||
"maintenance.model_maintenance_request"
|
||||
).id,
|
||||
"date_deadline": request.schedule_date
|
||||
- timedelta(days=planned_activity.date_before_request),
|
||||
}
|
||||
)
|
||||
return new_requests
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
# Copyright 2019-20 ForgeFlow S.L. (https://www.forgeflow.com)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class MiantenancePlannedactivity(models.Model):
|
||||
_name = "maintenance.planned.activity"
|
||||
_description = "Maintenance Planned Activity"
|
||||
|
||||
activity_type_id = fields.Many2one(
|
||||
"mail.activity.type", "Activity Type", required=True
|
||||
)
|
||||
user_id = fields.Many2one(
|
||||
"res.users", "Responsible", default=lambda self: self.env.user
|
||||
)
|
||||
date_before_request = fields.Integer(
|
||||
"# Days before request",
|
||||
help="This is the number of days the due date of the activity will be"
|
||||
"set before the Maintenance request scheduled date",
|
||||
)
|
||||
maintenance_plan_id = fields.Many2one("maintenance.plan", "Maintenance Plan")
|
||||
Loading…
Add table
Add a link
Reference in a new issue