Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0] [MIG] maintenance_plan #339

Merged
merged 109 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
cc84b0e
[ADD] maintenance_plan module (#2)
grindtildeath Oct 2, 2017
173e34f
[FIX] maintenance_plan: README try me on runbot link
pedrobaeza Nov 29, 2017
51dfdc6
[MIG] maintenance_plan: Migration to 11.0
bestmazzo Oct 25, 2018
07c93c6
[FIX] maintenance_plan: prevent preventive request cron crashing when…
dalonsod Jul 1, 2019
74983fc
[MIG] maintenance_plan: Migration to 12.0
dalonsod Jul 8, 2019
97322a3
Added translation using Weblate (Spanish)
lromero-solvos Jul 26, 2019
0b4f1bf
Translated using Weblate (Spanish)
lromero-solvos Jul 26, 2019
278086e
Added translation using Weblate (Chinese (Simplified))
liweijie0812 Sep 18, 2019
f9aefe4
[FIX] maintenance_plan: cron generated request should inherit equipme…
dalonsod Oct 15, 2019
8a2769c
[FIX] maintenance_plan: next_maintenance_date should be stored
dalonsod Oct 28, 2019
c9d1ed5
[12.0][IMP] maintenance_plan
AdriaGForgeFlow Jul 19, 2019
7213988
[11.0][IMP] maintenance_plan: Return the created requests
etobella Dec 24, 2019
cf06fc9
[12.0][FIX] maintenance_project_plan
etobella Dec 24, 2019
4c954f7
[12.0][FIX] default equipment_id in plans
Dec 13, 2019
c07f5ac
[12.0][IMP] maintenance_plan: Add team on plans
etobella Dec 24, 2019
258c87b
[FIX] maintenance_plan: prevent False as display name when name is empty
dalonsod Jan 2, 2020
6ee38c7
Translated using Weblate (Spanish)
dalonsod Jan 8, 2020
8f083b0
[IMP] maintenance_plan: black, isort
NuriaXifre Jan 14, 2020
547d342
[13.0][MIG] maintenance_plan
NuriaXifre Jan 14, 2020
d3586fc
[12.0][IMP] maintenance_plan: no equipment
Jan 22, 2020
42ffb8e
[FIX]maintenance_plan migration scripts not applicable in v13
AaronHForgeFlow May 19, 2020
24f3464
[13.0][IMP] maintenance_plan: make maintenance plan multi-company com…
LoisRForgeFlow Oct 29, 2020
de7cb34
maintenance_plan: manual version bump
LoisRForgeFlow Oct 29, 2020
8597e10
[IMP] maintenance_plan: black, isort, prettier
dalonsod Nov 15, 2020
c2fbd4e
[MIG] maintenance_plan: Migration to 14.0
dalonsod Nov 15, 2020
ed5e899
Added translation using Weblate (Italian)
mymage Jul 28, 2021
c51e084
Translated using Weblate (Italian)
mymage Jul 28, 2021
61f27f1
[FIX] maintenance_plan: Remake the computation of next date
etobella Sep 29, 2021
d5e34ec
Translated using Weblate (Italian)
mymage Oct 2, 2021
ff5e7bb
[IMP] maintenance_plan: next maintenance date tweaks
LoisRForgeFlow Oct 4, 2021
6e2715b
Translated using Weblate (Italian)
mymage Oct 16, 2021
92718ce
[IMP] maintenance_plan: black, isort, prettier
BernatPForgeFlow Oct 22, 2021
37a329e
[MIG] maintenance_plan: Migration to 15.0
BernatPForgeFlow Oct 22, 2021
c836944
[UPD] Update maintenance_plan.pot
Oct 27, 2021
7bfa3a0
[UPD] README.rst
OCA-git-bot Oct 27, 2021
9cd1444
[FIX] maintenance_plan: fix new request date when plan start date is …
mariadforgeflow Jan 21, 2022
3741772
maintenance_plan 15.0.1.0.1
OCA-git-bot Jan 26, 2022
e4c4f41
[FIX] maintenance_plan: avoid error if planning_step is not defined
MiquelRForgeFlow Jun 17, 2022
b4f3e45
[IMP] maintenance_plan: add chatter
mariadforgeflow Jul 19, 2022
f497214
[UPD] Update maintenance_plan.pot
Jul 25, 2022
2ff12eb
maintenance_plan 15.0.1.1.0
OCA-git-bot Jul 25, 2022
327d69f
Update translation files
oca-transbot Jul 25, 2022
25732fe
maintenance_plan 15.0.1.1.1
OCA-git-bot Jul 29, 2022
bd4a226
[15.0][FIX] maintenance_plan generate requests for inactive equipment
sergiocorato Oct 14, 2022
365472d
maintenance_plan 15.0.1.1.2
OCA-git-bot Oct 20, 2022
4511c19
Translated using Weblate (Italian)
mymage Oct 28, 2022
955a187
Translated using Weblate (Italian)
mymage Oct 31, 2022
576733e
[REF] moving function get_relativedelta to method
mymage Nov 23, 2022
cf5a2e9
Added translation using Weblate (Portuguese)
pedrocs-exo Dec 3, 2022
c6f236e
Translated using Weblate (Portuguese)
pedrocs-exo Dec 3, 2022
0199681
Translated using Weblate (Portuguese)
pedrocs-exo Dec 3, 2022
69fd73e
[UPD] Update maintenance_plan.pot
Dec 22, 2022
599deea
maintenance_plan 15.0.1.2.0
OCA-git-bot Dec 22, 2022
9d3debe
Update translation files
weblate Dec 22, 2022
2c85103
Translated using Weblate (Italian)
mymage Dec 23, 2022
f3102e4
Translated using Weblate (Italian)
mymage Dec 28, 2022
a3ec58f
Translated using Weblate (Italian)
francesco-ooops Dec 29, 2022
8b3954b
Translated using Weblate (Italian)
francesco-ooops Dec 30, 2022
d721803
Translated using Weblate (Italian)
francesco-ooops Jan 3, 2023
40c60ee
Translated using Weblate (Italian)
mymage Jan 11, 2023
4472d9d
Translated using Weblate (Italian)
mymage Feb 14, 2023
ff3f859
[FIX] maintenance_plan: fix maintence request form view
kluna1998 Jan 25, 2023
71894e2
[UPD] Update maintenance_plan.pot
Feb 20, 2023
6e15a90
maintenance_plan 15.0.1.3.0
OCA-git-bot Feb 20, 2023
77f0722
Update translation files
weblate Feb 20, 2023
68a94be
[IMP] maintenance_plan: Add instructions to request report.
victoralmau Feb 20, 2023
85b044f
[UPD] Update maintenance_plan.pot
Feb 21, 2023
b9137aa
maintenance_plan 15.0.1.4.0
OCA-git-bot Feb 21, 2023
29778b2
Update translation files
weblate Feb 21, 2023
6bf9939
[IMP] maintenance_plan: Add Generate requests for current threshold b…
victoralmau Feb 17, 2023
3e2ceee
[UPD] Update maintenance_plan.pot
Feb 22, 2023
87cfbda
maintenance_plan 15.0.1.5.0
OCA-git-bot Feb 22, 2023
1eedc2a
Update translation files
weblate Feb 22, 2023
f1b556d
[IMP] maintenance_plan: Set planned_hours in request from plan if mai…
victoralmau Jan 13, 2023
a088225
maintenance_plan 15.0.1.5.1
OCA-git-bot Feb 24, 2023
4b9c5a8
[IMP] maintenance_plan: Skip assigned mail + Activity mail of the req…
victoralmau Feb 27, 2023
aef2664
[UPD] Update maintenance_plan.pot
Mar 2, 2023
42a73fc
maintenance_plan 15.0.1.6.0
OCA-git-bot Mar 2, 2023
e8c1ee7
Update translation files
weblate Mar 2, 2023
4a05cab
[IMP] maintenance_plan: Change tests to allow inheritance
victoralmau Feb 24, 2023
4007c24
maintenance_plan 15.0.1.6.1
OCA-git-bot Mar 3, 2023
0b33c94
Translated using Weblate (Italian)
mymage Mar 8, 2023
fb2b4d9
Translated using Weblate (Italian)
mymage Apr 4, 2023
d3b55d4
Translated using Weblate (Italian)
mymage Apr 12, 2023
b6f3f1a
[IMP] maintenance_plan: Add rules to maintenance.plan to view records…
victoralmau Apr 14, 2023
610044a
maintenance_plan 15.0.1.7.0
OCA-git-bot Apr 19, 2023
60ebb9c
Translated using Weblate (Italian)
francesco-ooops Apr 26, 2023
3a33719
Translated using Weblate (Italian)
francesco-ooops May 12, 2023
34ba33c
Translated using Weblate (Italian)
francesco-ooops May 17, 2023
9b17904
Translated using Weblate (Spanish)
Ivorra78 Jun 30, 2023
4f5ccf6
Translated using Weblate (Spanish)
Ivorra78 Jul 6, 2023
cdbd500
Translated using Weblate (Italian)
francesco-ooops Jul 12, 2023
0faf110
Translated using Weblate (Italian)
mymage Aug 22, 2023
01e89a3
[UPD] README.rst
OCA-git-bot Sep 3, 2023
a9dfbb6
Translated using Weblate (Spanish)
Ivorra78 Sep 20, 2023
040711f
[UPD] Update maintenance_plan.pot
Oct 28, 2023
d6af8ee
Update translation files
weblate Oct 29, 2023
79d9bbc
[IMP] maintenance_plan: Add freeze_time to prevent errors in tests
victoralmau Oct 31, 2023
8e144d8
[BOT] post-merge updates
OCA-git-bot Oct 31, 2023
e5a64bc
[IMP] maintenance_plan: Allow to generate generic plans for multiple …
etobella Sep 6, 2023
c58ffc3
[FIX] maintenance_plan: The search must work with newIds
etobella Oct 24, 2023
973264a
[IMP] maintenance_plan: Add Team filter
etobella Oct 25, 2023
fba270b
[FIX] maintenance_plan: adapt tests
etobella Dec 11, 2023
791e46a
[UPD] Update maintenance_plan.pot
Dec 11, 2023
3bbff1c
[BOT] post-merge updates
OCA-git-bot Dec 11, 2023
da16664
Update translation files
weblate Dec 11, 2023
f5e28b8
Translated using Weblate (Italian)
mymage Dec 19, 2023
8787b38
[IMP] maintenance_plan: pre-commit stuff
alexeirivera87 Feb 1, 2024
106a09d
[MIG] maintenance_plan: Migration to 16.0
alexeirivera87 Feb 1, 2024
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
135 changes: 135 additions & 0 deletions maintenance_plan/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
================
Maintenance Plan
================

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

.. |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/licence-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/16.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-16-0/maintenance-16-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=16.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:

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:%2016.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 <akim.juillerat@camptocamp.com>
* Matteo Mazzoni <matteo@appcademy.tech>
* David Alonso <david.alonso@solvos.es>
* Adrià Gil Sorribes <adria.gil@forgeflow.com>
* Jordi Ballester Alomar <jordi.ballester@forgeflow.com>
* Lois Rilo <lois.rilo@forgeflow.com>
* Enric Tobella <enric.tobella@dixmit.com>
* Alexei Rivera <arivera@archeti.com>

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/16.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
25 changes: 25 additions & 0 deletions maintenance_plan/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# 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": "16.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",
"views/maintenance_kind_views.xml",
"views/maintenance_plan_views.xml",
"views/maintenance_equipment_views.xml",
"views/report_maintenance_request.xml",
],
"external_dependencies": {"python": ["dateutil"]},
"demo": ["data/demo_maintenance_plan.xml"],
"post_init_hook": "post_init_hook",
"installable": True,
}
57 changes: 57 additions & 0 deletions maintenance_plan/data/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>
52 changes: 52 additions & 0 deletions maintenance_plan/hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Copyright 2017 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

import logging

from odoo import SUPERUSER_ID, _, api
from odoo.exceptions import UserError


def post_init_hook(cr, registry):

logging.getLogger("odoo.addons.maintenance_plan").info(
"Migrating existing preventive maintenance"
)

env = api.Environment(cr, SUPERUSER_ID, {})

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

if equipments:

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

for equipment in equipments:
request = equipment.maintenance_ids.filtered(
lambda r: r.maintenance_type == "preventive"
and not r.stage_id.done
and r.request_date == equipment.next_action_date
)
if len(request) > 1:
raise UserError(
_(
"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.maintenance_duration,
"interval": equipment.period,
}
)
Loading
Loading