Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
138 commits
Select commit Hold shift + click to select a range
aec157c
[ADD] maintenance_plan module (#2)
grindtildeath Oct 2, 2017
5b3bc88
[FIX] maintenance_plan: README try me on runbot link
pedrobaeza Nov 29, 2017
a655c57
[MIG] maintenance_plan: Migration to 11.0
bestmazzo Oct 25, 2018
36dbc52
[FIX] maintenance_plan: prevent preventive request cron crashing when…
dalonsod Jul 1, 2019
82977ad
[MIG] maintenance_plan: Migration to 12.0
dalonsod Jul 8, 2019
ed41b21
Added translation using Weblate (Spanish)
lromero-solvos Jul 26, 2019
92c8da6
Translated using Weblate (Spanish)
lromero-solvos Jul 26, 2019
ec94c9d
Added translation using Weblate (Chinese (Simplified))
liweijie0812 Sep 18, 2019
5613bb7
[FIX] maintenance_plan: cron generated request should inherit equipme…
dalonsod Oct 15, 2019
96d17fb
[FIX] maintenance_plan: next_maintenance_date should be stored
dalonsod Oct 28, 2019
08fbf74
[12.0][IMP] maintenance_plan
AdriaGForgeFlow Jul 19, 2019
522a1df
[11.0][IMP] maintenance_plan: Return the created requests
etobella Dec 24, 2019
aeba047
[12.0][FIX] maintenance_project_plan
etobella Dec 24, 2019
7e86892
[12.0][FIX] default equipment_id in plans
Dec 13, 2019
133812b
[12.0][IMP] maintenance_plan: Add team on plans
etobella Dec 24, 2019
7be4e6d
[FIX] maintenance_plan: prevent False as display name when name is empty
dalonsod Jan 2, 2020
4125c45
Translated using Weblate (Spanish)
dalonsod Jan 8, 2020
8e4cc54
[IMP] maintenance_plan: black, isort
NuriaXifre Jan 14, 2020
7de4332
[13.0][MIG] maintenance_plan
NuriaXifre Jan 14, 2020
8cec32b
[12.0][IMP] maintenance_plan: no equipment
Jan 22, 2020
61a83ac
[FIX]maintenance_plan migration scripts not applicable in v13
AaronHForgeFlow May 19, 2020
c2736de
[13.0][IMP] maintenance_plan: make maintenance plan multi-company com…
LoisRForgeFlow Oct 29, 2020
b210b78
maintenance_plan: manual version bump
LoisRForgeFlow Oct 29, 2020
d91c8e5
[IMP] maintenance_plan: black, isort, prettier
dalonsod Nov 15, 2020
1b771c2
[MIG] maintenance_plan: Migration to 14.0
dalonsod Nov 15, 2020
42bc373
Added translation using Weblate (Italian)
mymage Jul 28, 2021
1839f6e
Translated using Weblate (Italian)
mymage Jul 28, 2021
85ebf80
[FIX] maintenance_plan: Remake the computation of next date
etobella Sep 29, 2021
4f3856b
Translated using Weblate (Italian)
mymage Oct 2, 2021
fd15e8d
[IMP] maintenance_plan: next maintenance date tweaks
LoisRForgeFlow Oct 4, 2021
e77c31c
Translated using Weblate (Italian)
mymage Oct 16, 2021
deaee90
[IMP] maintenance_plan: black, isort, prettier
BernatPForgeFlow Oct 22, 2021
5a7c037
[MIG] maintenance_plan: Migration to 15.0
BernatPForgeFlow Oct 22, 2021
0a17efc
[UPD] Update maintenance_plan.pot
Oct 27, 2021
2529a87
[UPD] README.rst
OCA-git-bot Oct 27, 2021
61464a4
[FIX] maintenance_plan: fix new request date when plan start date is …
mariadforgeflow Jan 21, 2022
dbc5cf8
maintenance_plan 15.0.1.0.1
OCA-git-bot Jan 26, 2022
902f91d
[FIX] maintenance_plan: avoid error if planning_step is not defined
MiquelRForgeFlow Jun 17, 2022
1438702
[IMP] maintenance_plan: add chatter
mariadforgeflow Jul 19, 2022
4418d51
[UPD] Update maintenance_plan.pot
Jul 25, 2022
53a77f8
maintenance_plan 15.0.1.1.0
OCA-git-bot Jul 25, 2022
3dd72cb
Update translation files
oca-transbot Jul 25, 2022
c87cd97
maintenance_plan 15.0.1.1.1
OCA-git-bot Jul 29, 2022
c18ff60
[15.0][FIX] maintenance_plan generate requests for inactive equipment
sergiocorato Oct 14, 2022
5a03fad
maintenance_plan 15.0.1.1.2
OCA-git-bot Oct 20, 2022
1bdf9fe
Translated using Weblate (Italian)
mymage Oct 28, 2022
8a894ac
Translated using Weblate (Italian)
mymage Oct 31, 2022
ffccf73
[REF] moving function get_relativedelta to method
mymage Nov 23, 2022
c1f4e42
Added translation using Weblate (Portuguese)
pedrocs-exo Dec 3, 2022
b87de76
Translated using Weblate (Portuguese)
pedrocs-exo Dec 3, 2022
05f30cc
Translated using Weblate (Portuguese)
pedrocs-exo Dec 3, 2022
273bce0
[UPD] Update maintenance_plan.pot
Dec 22, 2022
5601cc4
maintenance_plan 15.0.1.2.0
OCA-git-bot Dec 22, 2022
05491d5
Update translation files
weblate Dec 22, 2022
66aee0e
Translated using Weblate (Italian)
mymage Dec 23, 2022
3d297d1
Translated using Weblate (Italian)
mymage Dec 28, 2022
4286b9e
Translated using Weblate (Italian)
francesco-ooops Dec 29, 2022
1ffe4c1
Translated using Weblate (Italian)
francesco-ooops Dec 30, 2022
c0e8076
Translated using Weblate (Italian)
francesco-ooops Jan 3, 2023
ccab3f5
Translated using Weblate (Italian)
mymage Jan 11, 2023
6f55b7c
Translated using Weblate (Italian)
mymage Feb 14, 2023
a14d225
[FIX] maintenance_plan: fix maintence request form view
kluna1998 Jan 25, 2023
42332e3
[UPD] Update maintenance_plan.pot
Feb 20, 2023
5892c69
maintenance_plan 15.0.1.3.0
OCA-git-bot Feb 20, 2023
ac4ee8f
Update translation files
weblate Feb 20, 2023
7d7d010
[IMP] maintenance_plan: Add instructions to request report.
victoralmau Feb 20, 2023
f8fb382
[UPD] Update maintenance_plan.pot
Feb 21, 2023
8831253
maintenance_plan 15.0.1.4.0
OCA-git-bot Feb 21, 2023
22d2bdd
Update translation files
weblate Feb 21, 2023
869a6a2
[IMP] maintenance_plan: Add Generate requests for current threshold b…
victoralmau Feb 17, 2023
d2d10f5
[UPD] Update maintenance_plan.pot
Feb 22, 2023
a36b3f4
maintenance_plan 15.0.1.5.0
OCA-git-bot Feb 22, 2023
ef9de69
Update translation files
weblate Feb 22, 2023
dc56029
[IMP] maintenance_plan: Set planned_hours in request from plan if mai…
victoralmau Jan 13, 2023
7e4b5aa
maintenance_plan 15.0.1.5.1
OCA-git-bot Feb 24, 2023
a46ace2
[IMP] maintenance_plan: Skip assigned mail + Activity mail of the req…
victoralmau Feb 27, 2023
8d619a9
[UPD] Update maintenance_plan.pot
Mar 2, 2023
9116e6a
maintenance_plan 15.0.1.6.0
OCA-git-bot Mar 2, 2023
97de511
Update translation files
weblate Mar 2, 2023
bab0fb0
[IMP] maintenance_plan: Change tests to allow inheritance
victoralmau Feb 24, 2023
dab653a
maintenance_plan 15.0.1.6.1
OCA-git-bot Mar 3, 2023
69e3976
Translated using Weblate (Italian)
mymage Mar 8, 2023
7f7a419
Translated using Weblate (Italian)
mymage Apr 4, 2023
ca64c77
Translated using Weblate (Italian)
mymage Apr 12, 2023
0c2ff25
[IMP] maintenance_plan: Add rules to maintenance.plan to view records…
victoralmau Apr 14, 2023
f3390da
maintenance_plan 15.0.1.7.0
OCA-git-bot Apr 19, 2023
95029fe
Translated using Weblate (Italian)
francesco-ooops Apr 26, 2023
bea345e
Translated using Weblate (Italian)
francesco-ooops May 12, 2023
96593aa
Translated using Weblate (Italian)
francesco-ooops May 17, 2023
3d0cbe5
Translated using Weblate (Spanish)
Ivorra78 Jun 30, 2023
cd84bd2
Translated using Weblate (Spanish)
Ivorra78 Jul 6, 2023
6fe83ec
Translated using Weblate (Italian)
francesco-ooops Jul 12, 2023
1dd7870
Translated using Weblate (Italian)
mymage Aug 22, 2023
80d170d
[UPD] README.rst
OCA-git-bot Sep 3, 2023
8881488
Translated using Weblate (Spanish)
Ivorra78 Sep 20, 2023
cbc5557
[UPD] Update maintenance_plan.pot
Oct 28, 2023
dfc2d76
Update translation files
weblate Oct 29, 2023
d502413
[IMP] maintenance_plan: Add freeze_time to prevent errors in tests
victoralmau Oct 31, 2023
1d7f869
[BOT] post-merge updates
OCA-git-bot Oct 31, 2023
8bbd3fb
[IMP] maintenance_plan: Allow to generate generic plans for multiple …
etobella Sep 6, 2023
ccb3b83
[FIX] maintenance_plan: The search must work with newIds
etobella Oct 24, 2023
15bb642
[IMP] maintenance_plan: Add Team filter
etobella Oct 25, 2023
a4d28d6
[FIX] maintenance_plan: adapt tests
etobella Dec 11, 2023
cb8fde8
[UPD] Update maintenance_plan.pot
Dec 11, 2023
a81cfbb
[BOT] post-merge updates
OCA-git-bot Dec 11, 2023
192b34c
Update translation files
weblate Dec 11, 2023
cdb33e5
Translated using Weblate (Italian)
mymage Dec 19, 2023
d413a40
[MIG] maintenance_plan: Migration to 16.0
alexeirivera87 Feb 1, 2024
4a46d65
[UPD] Update maintenance_plan.pot
Feb 2, 2024
9145a13
Translated using Weblate (Spanish)
Ivorra78 Feb 3, 2024
213123e
[IMP] maintenance_plan: pre-commit auto fixes
FernandoRomera Jul 23, 2024
25a9f54
[MIG] maintenance_plan: Migration to 17.0
FernandoRomera Jul 23, 2024
d919959
[UPD] Update maintenance_plan.pot
Aug 8, 2024
1c95ccd
[BOT] post-merge updates
OCA-git-bot Aug 8, 2024
71a5d0d
[UPD] Update maintenance_plan.pot
Aug 20, 2024
d462ea7
Update translation files
weblate Aug 20, 2024
c165a6e
Translated using Weblate (Italian)
mymage Aug 20, 2024
eaf57fa
[FIX] maintenance_plan: fix the use of id in act_window
vincent-hatakeyama Nov 28, 2024
1d451f8
Translated using Weblate (Italian)
mymage Dec 17, 2024
65a64e6
Translated using Weblate (Italian)
mymage Dec 31, 2024
5862a25
[IMP] base_maintenance: Fine-tuning of the form view
carlos-lopez-tecnativa Jan 14, 2025
8528bfa
[UPD] Update maintenance_plan.pot
Jan 15, 2025
f9235fa
[BOT] post-merge updates
OCA-git-bot Jan 15, 2025
331f095
Update translation files
weblate Jan 15, 2025
22f3733
[BOT] post-merge updates
OCA-git-bot Jan 15, 2025
d12f84e
[IMP] maintenance_plan: Define module as deprecated in readme
victoralmau Feb 20, 2025
e33278f
[BOT] post-merge updates
OCA-git-bot Mar 13, 2025
da0b7cc
[IMP] maintenance_plan: pre-commit auto fixes
ypapouin Oct 28, 2025
1b98913
[MIG] maintenance_plan: Migration to 18.0
ypapouin Oct 28, 2025
dece151
[IMP] maintenance_plan: Remove "deprecated" status
ypapouin Oct 16, 2025
f1a6448
[FIX] maintenance_plan: Odoo dependency flaw
ypapouin Oct 21, 2025
9e3e3e4
[IMP] maintenance_plan: Replace note with instructions
ypapouin Nov 20, 2025
637806d
[IMP] maintenance_plan: Path added to actions
ypapouin Oct 20, 2025
c017373
[IMP] maintenance_plan: Setting added to install "maintenance_plan_on…
ypapouin Nov 20, 2025
ee4b909
[UPD] Update maintenance_plan.pot
Nov 27, 2025
18e9f50
[BOT] post-merge updates
OCA-git-bot Nov 27, 2025
5ae816f
[IMP] maintenance_plan: pre-commit auto fixes
JasminSForgeFlow Dec 3, 2025
423f7a8
[MIG] maintenance_plan: Migration to 19.0
JasminSForgeFlow Dec 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
159 changes: 159 additions & 0 deletions maintenance_plan/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

================
Maintenance Plan
================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:cd21f05e56ccccd12e88d22a3009fd970401a379a695813d5815b03ed56303a2
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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/license-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/19.0/maintenance_plan
:alt: OCA/maintenance
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/maintenance-19-0/maintenance-19-0-maintenance_plan
: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=19.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module extends the functionality of Odoo Maintenance module by
allowing an equipment to have different preventive maintenance kinds.

**Table of contents**

.. contents::
:local:

Use Cases / Context
===================

Despite Odoo's built-in recurrence functionality included in the
maintenance requests themselves (since 17.0), this module could be
needed for some reasons:

- Odoo implementation is javascript only
- Some companies already work with the existing "Maintenance Plan"
workflow
- Some modules are depending on this one

For reference, this module was initially set deprecated when migrated to
17.0:
https://github.com/OCA/maintenance/pull/414#issuecomment-2668929617

Installation
============

Install the module.

Should you already use the maintenance module and have equipments with
field 'Preventive Maintenance Frequency' defined, a new maintenance plan
will be automatically created on these equipments with maintenance kind
'Install'.

Moreover if a Request of type 'preventive' exists, whose stage isn't
marked as 'Request done', and has a Request Date matching the
equipment's 'Next Preventive Maintenance', the request will be updated
with the 'Install' maintenance kind.

Make sure you don't have multiple 'preventive' requests at a stage which
isn't marked as 'Request done' and on the same 'Request date' as the
equipment or the module installation will fail with a User Error.

Usage
=====

Instead of defining a period and duration for only one preventive
maintenance per equipment, you can define multiple preventive
maintenance kind for each equipment.

Maintenance Kinds have to be defined through the configuration menu.
Their name have to be unique and can be set as active or inactive,
should these not be used anymore.

On any equipment over the maintenance tab, the maintenance plan be
accessible, allowing to add different maintenance kind with their own
frequency and duration. The next maintenance date will then be computed
automatically according to the start's date and the frequency defined,
but the maintenance request won't be created automatically as is the
case in Odoo's Maintenance module. In the plan there's also a field
allowing the user to set the maintenance horizon, insert the
instructions to follow on the maintenance that will be forwarded to the
maintenance request generated from the plan.

This module uses the original Cron job of Odoo's Maintenance module to
generate maintenance requests. To do so, it takes into account the
planning horizon and generates all maintenance requests whose schedule
date would fall inside that planning horizon. Therefore, the maintenance
manager can have a proper planning of how many maintenance requests are
programming for the future. Leaving planning horizon to 0 will only
create those maintenance request that are scheduled for today.

We can also create maintenance requests from a plan using a domain for
selecting the equipments. This way, we might have a single plan that
will generate all the requests. In order to use it, we need to mark the
Generate with Domain field.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/maintenance/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 <https://github.com/OCA/maintenance/issues/new?body=module:%20maintenance_plan%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* Camptocamp SA
* ForgeFlow

Contributors
------------

- Akim Juillerat <[email protected]>
- Matteo Mazzoni <[email protected]>
- David Alonso <[email protected]>
- Adrià Gil Sorribes <[email protected]>
- Jordi Ballester Alomar <[email protected]>
- Lois Rilo <[email protected]>
- Enric Tobella <[email protected]>
- Alexei Rivera <[email protected]>
- Yann Papouin <[email protected]>

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 <https://github.com/OCA/maintenance/tree/19.0/maintenance_plan>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions maintenance_plan/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import models
from .hooks import post_init_hook
28 changes: 28 additions & 0 deletions maintenance_plan/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright 2017 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Maintenance Plan",
"summary": "Extends preventive maintenance planning",
"version": "19.0.1.0.0",
"author": "Camptocamp SA, ForgeFlow, Odoo Community Association (OCA)",
"license": "AGPL-3",
"category": "Maintenance",
"website": "https://github.com/OCA/maintenance",
"images": [],
"depends": ["base_maintenance"],
"data": [
"security/ir.model.access.csv",
"security/maintenance_security.xml",
"data/ir_cron.xml",
"views/maintenance_request_views.xml",
"views/maintenance_kind_views.xml",
"views/maintenance_plan_views.xml",
"views/maintenance_equipment_views.xml",
"views/report_maintenance_request.xml",
"views/res_config_settings.xml",
],
"external_dependencies": {"python": ["python-dateutil"]},
"demo": ["demo/demo_maintenance_plan.xml"],
"post_init_hook": "post_init_hook",
"installable": True,
}
11 changes: 11 additions & 0 deletions maintenance_plan/data/ir_cron.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding='UTF-8' ?>
<odoo>
<record id="maintenance_requests_cron" model="ir.cron">
<field name="name">Maintenance: generate preventive maintenance requests</field>
<field name="model_id" ref="model_maintenance_equipment" />
<field name="state">code</field>
<field name="code">model._cron_generate_requests()</field>
<field name="interval_number">1</field>
<field name="interval_type">days</field>
</record>
</odoo>
57 changes: 57 additions & 0 deletions maintenance_plan/demo/demo_maintenance_plan.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1">
<!-- Maintenance kinds -->
<record id="maintenance_kind_monthly" model="maintenance.kind">
<field name="name">Monthly</field>
<field name="active" eval="True" />
</record>
<record id="maintenance_kind_weekly" model="maintenance.kind">
<field name="name">Weekly</field>
<field name="active" eval="True" />
</record>
<!-- Maintenance plans -->
<record id="maintenance_plan_monthly_monitor1" model="maintenance.plan">
<field name="equipment_id" ref="maintenance.equipment_monitor1" />
<field name="maintenance_kind_id" ref="maintenance_kind_monthly" />
<field name="interval">1</field>
<field name="interval_step">month</field>
<field name="duration">2</field>
<field name="maintenance_plan_horizon">2</field>
<field name="planning_step">month</field>
</record>
<record id="maintenance_plan_monthly_monitor4" model="maintenance.plan">
<field name="equipment_id" ref="maintenance.equipment_monitor4" />
<field name="maintenance_kind_id" ref="maintenance_kind_monthly" />
<field name="interval">1</field>
<field name="interval_step">month</field>
<field name="duration">2</field>
<field name="maintenance_plan_horizon">2</field>
<field name="planning_step">month</field>
</record>
<record id="maintenance_plan_monthly_monitor6" model="maintenance.plan">
<field name="equipment_id" ref="maintenance.equipment_monitor6" />
<field name="maintenance_kind_id" ref="maintenance_kind_monthly" />
<field name="interval">1</field>
<field name="interval_step">month</field>
<field name="duration">2</field>
<field name="maintenance_plan_horizon">1</field>
<field name="planning_step">month</field>
</record>
<record id="maintenance_plan_monthly_printer1" model="maintenance.plan">
<field name="equipment_id" ref="maintenance.equipment_printer1" />
<field name="maintenance_kind_id" ref="maintenance_kind_monthly" />
<field name="interval">1</field>
<field name="interval_step">month</field>
<field name="duration">4</field>
<field name="maintenance_plan_horizon">3</field>
<field name="planning_step">month</field>
</record>
<record id="maintenance_plan_weekly_printer1" model="maintenance.plan">
<field name="equipment_id" ref="maintenance.equipment_printer1" />
<field name="maintenance_kind_id" ref="maintenance_kind_weekly" />
<field name="interval">7</field>
<field name="duration">2</field>
<field name="maintenance_plan_horizon">1</field>
<field name="planning_step">month</field>
</record>
</odoo>
47 changes: 47 additions & 0 deletions maintenance_plan/hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Copyright 2017 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

import logging

from odoo.exceptions import UserError


def post_init_hook(env):
logging.getLogger("odoo.addons.maintenance_plan").info(
"Migrating existing preventive maintenance"
)

equipments = env["maintenance.equipment"].search([("expected_mtbf", "!=", False)])

if equipments:
maintenance_kind = env["maintenance.kind"].create(
{"name": "Install", "active": True}
)

for equipment in equipments:
request = equipment.maintenance_ids.filtered(
lambda r, equipment=equipment: r.maintenance_type == "preventive"
and not r.stage_id.done
and r.request_date == equipment.next_action_date
)
if len(request) > 1:
raise UserError(
env._(
"You have multiple preventive maintenance requests on "
"equipment %(name)s next action date (%(date)s). "
"Please leave only one preventive request on the "
"date of equipment's next action to install the module.",
name=equipment.name,
date=equipment.next_action_date,
)
)
elif len(request) == 1:
request.write({"maintenance_kind_id": maintenance_kind.id})
env["maintenance.plan"].create(
{
"equipment_id": equipment.id,
"maintenance_kind_id": maintenance_kind.id,
"duration": equipment.mtbf,
"interval": equipment.expected_mtbf,
}
)
Loading
Loading