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

[17.0][ADD] fieldservice_recurring_repair #1250

Open
wants to merge 1 commit into
base: 17.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
134 changes: 134 additions & 0 deletions fieldservice_recurring_repair/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
==============================
Field Service Recurring Repair
==============================

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

.. |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%2Ffield--service-lightgray.png?logo=github
:target: https://github.com/OCA/field-service/tree/17.0/fieldservice_recurring_repair
:alt: OCA/field-service
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/field-service-17-0/field-service-17-0-fieldservice_recurring_repair
: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/field-service&target_branch=17.0
:alt: Try me on Runboat

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

This module allows you to manage your recurring field service work
orders linked to repairs.

As repairs are often recurring and ``fieldservice_repair`` accept only
one equipment, this module allows you to create a recurring work order
for several equipments. This way, you can create a recurring order for a
group of equipments and the ``fsm.order`` will be created for each
equipment.

**Table of contents**

.. contents::
:local:

Configuration
=============

To configure this module, you need to:

- Follow the steps to configure ``fieldservice_repair`` module and
``fieldservice_recurring``

Usage
=====

To use this module, you can:

1. Create ``fsm.order.type`` Maintenance with internal type = Repair
2. Create ``fsm.template`` Maintenance with type Maintenance (created on
step 1)
3. Create a ``fsm.recurring.template`` Daily Maintenance with

- order template = maintenance (created on step 2)

4. Create a SO with a product with creation of new equipment activated
and the generation of recurring orders.
5. Confirm and deliver → you get a new ``fsm.equipment`` linked to the
delivered product and a ``fsm.recurring.order`` linked to the SO:
6. On the ``fsm.recurring.order``:

- set the equipment to the one delivered

7. click Start

This will create one ``fsm.order`` per equipment and one
``repair.order`` by ``fsm.order``.

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/field-service/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/field-service/issues/new?body=module:%20fieldservice_recurring_repair%0Aversion:%2017.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
-------

* Italo Lopes
* Camptocamp

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

- Italo Lopes <[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.

.. |maintainer-wolfhall| image:: https://github.com/wolfhall.png?size=40px
:target: https://github.com/wolfhall
:alt: wolfhall
.. |maintainer-max3903| image:: https://github.com/max3903.png?size=40px
:target: https://github.com/max3903
:alt: max3903
.. |maintainer-brian10048| image:: https://github.com/brian10048.png?size=40px
:target: https://github.com/brian10048
:alt: brian10048
.. |maintainer-imlopes| image:: https://github.com/imlopes.png?size=40px
:target: https://github.com/imlopes
:alt: imlopes

Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-wolfhall| |maintainer-max3903| |maintainer-brian10048| |maintainer-imlopes|

This module is part of the `OCA/field-service <https://github.com/OCA/field-service/tree/17.0/fieldservice_recurring_repair>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
5 changes: 5 additions & 0 deletions fieldservice_recurring_repair/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright 2024 Camptocamp
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).


from . import models
16 changes: 16 additions & 0 deletions fieldservice_recurring_repair/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2024 Camptocamp SA (https://www.camptocamp.com).
# @author: Italo Lopes <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Field Service Recurring Repair",
"summary": "Manage recurring Field Service orders for repairs",
"version": "17.0.1.1.0",
"category": "Field Service",
"author": "Italo Lopes, " "Camptocamp, " "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/field-service",
"depends": ["fieldservice_recurring", "fieldservice_repair"],
"license": "AGPL-3",
"development_status": "Beta",
"maintainers": ["wolfhall", "max3903", "brian10048", "imlopes"],
}
6 changes: 6 additions & 0 deletions fieldservice_recurring_repair/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Copyright 2024 Camptocamp SA (https://www.camptocamp.com).
# @author: Italo Lopes <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).


from . import fsm_recurring
44 changes: 44 additions & 0 deletions fieldservice_recurring_repair/models/fsm_recurring.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Copyright 2024 Camptocamp SA (https://www.camptocamp.com).
# @author: Italo Lopes <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import models


class FSMRecurringOrder(models.Model):
_inherit = "fsm.recurring"

def _split_create_by_equipment(self, vals):
"""
Create an order for each equipment.
On fieldservice_repair, we create a repair order for each equipment.
"""
self.ensure_one()
orders = self.env["fsm.order"]
for equipment in self.equipment_ids:
order_vals = vals.copy()
order_vals["equipment_id"] = equipment.id
orders |= self.env["fsm.order"].create(order_vals)
return orders
Comment on lines +17 to +22

Choose a reason for hiding this comment

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

Suggested change
orders = self.env["fsm.order"]
for equipment in self.equipment_ids:
order_vals = vals.copy()
order_vals["equipment_id"] = equipment.id
orders |= self.env["fsm.order"].create(order_vals)
return orders
return self.env["fsm.order"].create(
[
dict(vals, equipment_id=equipment.id)
for equipment in self.equipment_ids
]
)

nitpicking: to create all at once (better for perf)


def _should_create_by_equipment(self):
return bool(
self.fsm_order_template_id
and self.fsm_order_template_id.type_id
and self.fsm_order_template_id.type_id.internal_type == "repair"
)
Comment on lines +25 to +29

Choose a reason for hiding this comment

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

💡 tip: This is exactly the same as:

Suggested change
return bool(
self.fsm_order_template_id
and self.fsm_order_template_id.type_id
and self.fsm_order_template_id.type_id.internal_type == "repair"
)
return self.fsm_order_template_id.type_id.internal_type == "repair"


def _create_order(self, date):
# Originally this method return only a single fsm.order.
# This method has been modified to return multiple fsm.order
# as we are creating multiple orders based on equipments.
self.ensure_one()
if self._should_create_by_equipment():
vals = self._prepare_order_values(date)
orders = self._split_create_by_equipment(vals)
for order in orders:
order._onchange_template_id()
else:
orders = super()._create_order(date)
orders._onchange_template_id()

Choose a reason for hiding this comment

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

Suggested change
orders._onchange_template_id()

Already done by super, isn't it?

return orders
3 changes: 3 additions & 0 deletions fieldservice_recurring_repair/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
3 changes: 3 additions & 0 deletions fieldservice_recurring_repair/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
To configure this module, you need to:

- Follow the steps to configure ``fieldservice_repair`` module and ``fieldservice_recurring``
1 change: 1 addition & 0 deletions fieldservice_recurring_repair/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Italo Lopes \<<[email protected]>\>
8 changes: 8 additions & 0 deletions fieldservice_recurring_repair/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
This module allows you to manage your recurring field service work
orders linked to repairs.

As repairs are often recurring and `fieldservice_repair` accept only one
equipment, this module allows you to create a recurring work order for several
equipments. This way, you can create a recurring order for a group of equipments
and the `fsm.order` will be created for each equipment.

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change

15 changes: 15 additions & 0 deletions fieldservice_recurring_repair/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
To use this module, you can:

1. Create `fsm.order.type` Maintenance with internal type = Repair
2. Create `fsm.template` Maintenance with type Maintenance (created on step 1)
3. Create a `fsm.recurring.template` Daily Maintenance with
- order template = maintenance (created on step 2)
4. Create a SO with a product with creation of new equipment activated
and the generation of recurring orders.
5. Confirm and deliver → you get a new `fsm.equipment` linked to the delivered product
and a `fsm.recurring.order` linked to the SO:
6. On the `fsm.recurring.order`:
- set the equipment to the one delivered
7. click Start

This will create one `fsm.order` per equipment and one `repair.order` by `fsm.order`.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
This will create one `fsm.order` per equipment and one `repair.order` by `fsm.order`.
This will create one `fsm.order` per equipment and one `repair.order` per `fsm.order`.

Copy link
Member

Choose a reason for hiding this comment

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

@imlopes Can you use the latest logo from fieldservice?

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading