Skip to content

Conversation

@grindtildeath
Copy link
Contributor

@grindtildeath grindtildeath commented Jun 9, 2017

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

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

Installation

Install the module.

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 will appear
as an embedded list view, allowing to add different maintenance kind with their
own period and duration. The next maintenance date will then be computed
automatically according to today's date and the period defined, but the
maintenance request won't be created automatically as is the case in Odoo's
Maintenance module.

Instead, this module uses the original Cron job of Odoo's Maintenance module
to generate maintenance requests, should there not be any requests which is not
done, at the request date matching the maintenance plan next_maintenance_date
for this equipment and this maintenance kind !

@dreispt
Copy link
Member

dreispt commented Jun 9, 2017

LGTM; please fix TravisCI

Suggestions/questions

  • It would be nice to have an action/button on "Equipment" to "Generate Next Maintenance"; the corresponding method would reused by the cron job.
  • Wouldn't month duration be better for the maintenance intervals? Either way, it could be a nice addition to also have a duration UoM selector - "Days" or "Months".

@grindtildeath grindtildeath force-pushed the add_maintenance_plan branch from dddec62 to 07a2f54 Compare June 9, 2017 09:23
@grindtildeath
Copy link
Contributor Author

@dreispt
Thanks for your suggestions.

  • We didn't code the 'Generate next maintenance' button as it would be used only at the creation of a new plan and the idea was to create all the maintenance plans and then run the ir.cron manually, should the requests be generated before it runs automatically.
  • A duration UoM could also be useful, but we wanted to keep it as simple as possible to begin with.

IMO both could be nice addition to the module, but I don't have time to spend on these features at the moment.

@dreispt
Copy link
Member

dreispt commented Jun 9, 2017

@grindtildeath That's why I mentioned them as suggestion ideas.

@dreispt
Copy link
Member

dreispt commented Jun 9, 2017

Does this have any conflict with the standard module's planned maintenance generation, if both are configured?
Does it disable it or will both will work?

Or from a user PoV:
have planned maintenance configured on my Equipments, and I then install this.
What is the impact and what do I need to take care to get everything right?

@grindtildeath
Copy link
Contributor Author

@dreispt
I added a post-init hook, with the description in README.rst of what will happen and what should be done before installing should the standard feature already bu used.
Feel free to let me know what could be improved.

@grindtildeath grindtildeath force-pushed the add_maintenance_plan branch from dd33d59 to 06d8d54 Compare June 16, 2017 10:26
@dreispt dreispt added this to the 10.0 milestone Jun 16, 2017
@dreispt dreispt requested review from dreispt and pedrobaeza June 16, 2017 16:48
Copy link
Member

@dreispt dreispt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but made a few comements

})

@api.model
def _cron_generate_requests(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is to be used by a Cron it is an external API, so the name method should not start with an underscore.
Furthermore, I can see this used in a Button somewhere, so I suggest renaming it to "do_generate_requests" and expand the docstring to explain that ii can bu used by a cron job.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your review.
However, as this method is called by standard ir.cron from maintenance module, I suppose it's better to leave its name as it is, so we don't have to update the existing ir.cron :
https://github.com/odoo/odoo/blob/10.0/addons/maintenance/data/maintenance_cron.xml#L10

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, OK then.

<record id="maintenance_kind_view_search" model="ir.ui.view">
<field name="name">maintenance.kind.search</field>
<field name="model">maintenance.kind</field>
<field name="arch" type="xml">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This view is redundant - Odoo does name searches by default.

def _create_new_request(self, maintenance_plan):
self.ensure_one()
self.env['maintenance.request'].create({
'name': _('Preventive Maintenance (%s) - %s') %
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please extract the dict creation into it's own _prepare_new_maintenance_request method, so that it is easy to extend it.

Copy link

@elicoidal elicoidal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some details and one question on contraint

# Copyright 2017 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{'name': 'Maintenance Plan',
'version': '10.0.1.0.0',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a summary would be welcome

"You have multiple preventive maintenance requests on an "
"equipment's next action date. Please leave only one "
"request as preventive on the date of equipment's next "
"action to install the module."))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice to have: indicate which record are faulty


_sql_constraints = [
('name_uniq', 'unique (name)',
"Maintenance kind name already exists !")]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove exclamation mark

date_gap = fields.Date.from_string(
next_maintenance_todo.request_date) - \
fields.Date.from_string(last_maintenance_done.close_date)
# If the gap between the last_maintenance_done and the

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This look like specific rule that might not apply everywhere

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@elicoidal Thanks for your review.

This code is an adaptation from odoo to keep the behaviour as close as possible to standard module : https://github.com/odoo/odoo/blob/10.0/addons/maintenance/models/maintenance.py#L165

_sql_constraints = [
('equipment_kind_uniq', 'unique (equipment_id, maintenance_kind_id)',
"You cannot define multiple times the same maintenance kind on an "
"equipment maintenance plan!")]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove exclamation mark.

@dreispt
Copy link
Member

dreispt commented Aug 22, 2017

@elicoidal can you review the changes please?

dalonsod referenced this pull request in solvosci/maintenance Jul 8, 2019
NuriaXifre pushed a commit to ForgeFlow/maintenance that referenced this pull request Jan 13, 2020
NuriaXifre pushed a commit to ForgeFlow/maintenance that referenced this pull request Jan 13, 2020
NuriaXifre pushed a commit to ForgeFlow/maintenance that referenced this pull request Jan 13, 2020
NuriaXifre pushed a commit to ForgeFlow/maintenance that referenced this pull request Jan 13, 2020
NuriaXifre pushed a commit to ForgeFlow/maintenance that referenced this pull request Jan 14, 2020
NuriaXifre pushed a commit to ForgeFlow/maintenance that referenced this pull request Feb 4, 2020
OCA-git-bot pushed a commit that referenced this pull request Nov 17, 2020
BernatPForgeFlow pushed a commit to ForgeFlow/maintenance that referenced this pull request Oct 22, 2021
FernandoRomera pushed a commit to MallorcaSoft/maintenance that referenced this pull request Dec 9, 2022
FernandoRomera pushed a commit to MallorcaSoft/maintenance that referenced this pull request Dec 20, 2022
vibhascs pushed a commit to vibhascs/maintenance that referenced this pull request Jan 13, 2023
YvanDotet pushed a commit to YvanDotet/maintenance that referenced this pull request Mar 23, 2023
alexeirivera87 pushed a commit to archeti-org/maintenance that referenced this pull request Jun 14, 2023
brian10048 pushed a commit to brian10048/maintenance that referenced this pull request Nov 22, 2023
renda-dev pushed a commit to PyTech-SRL/maintenance that referenced this pull request Nov 27, 2023
alexeirivera87 pushed a commit to archeti-org/maintenance that referenced this pull request Jan 30, 2024
alexeirivera87 pushed a commit to archeti-org/maintenance that referenced this pull request Feb 1, 2024
FernandoRomera pushed a commit to FernandoRomera/maintenance that referenced this pull request Jul 23, 2024
BhaveshHeliconia pushed a commit to HeliconiaIO/maintenance that referenced this pull request Jan 27, 2025
gbrito pushed a commit to gbrito/maintenance that referenced this pull request Oct 3, 2025
ypapouin pushed a commit to decgroupe/maintenance that referenced this pull request Oct 28, 2025
ypapouin pushed a commit to decgroupe/maintenance that referenced this pull request Oct 28, 2025
ypapouin pushed a commit to decgroupe/maintenance that referenced this pull request Oct 28, 2025
ypapouin pushed a commit to decgroupe/maintenance that referenced this pull request Oct 28, 2025
ypapouin pushed a commit to decgroupe/maintenance that referenced this pull request Oct 29, 2025
ypapouin pushed a commit to decgroupe/maintenance that referenced this pull request Nov 21, 2025
JasminSForgeFlow pushed a commit to ForgeFlow/maintenance that referenced this pull request Nov 26, 2025
JasminSForgeFlow pushed a commit to ForgeFlow/maintenance that referenced this pull request Dec 3, 2025
JasminSForgeFlow pushed a commit to ForgeFlow/maintenance that referenced this pull request Dec 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants