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_repair_order_template #1271

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
93 changes: 93 additions & 0 deletions fieldservice_repair_order_template/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
=====================================
Field Service - Repair Order Template
=====================================

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

.. |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_repair_order_template
: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_repair_order_template
: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|

Use the **Repair Order Templates** to pre-fill some fields on the
generated repair orders.

**Table of contents**

.. contents::
:local:

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

Go to **Field Service > Master Data > Templates** and select the desired
**Repair Order Template**.

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_repair_order_template%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
-------

* Camptocamp

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

- `Camptocamp <https://camptocamp.com/>`__:

- Iván Todorovich <[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-ivantodorovich| image:: https://github.com/ivantodorovich.png?size=40px
:target: https://github.com/ivantodorovich
:alt: ivantodorovich

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

|maintainer-ivantodorovich|

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

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

{
"name": "Field Service - Repair Order Template",
"summary": "Use Repair Order Templates when creating a repair orders",
"version": "17.0.1.0.0",
"author": "Camptocamp, Odoo Community Association (OCA)",
"maintainers": ["ivantodorovich"],
"website": "https://github.com/OCA/field-service",
"license": "AGPL-3",
"category": "Field Service",
"depends": [
"fieldservice_repair",
"repair_order_template",
],
"data": [
"views/fsm_template.xml",
],
}
2 changes: 2 additions & 0 deletions fieldservice_repair_order_template/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import fsm_order
from . import fsm_template
40 changes: 40 additions & 0 deletions fieldservice_repair_order_template/models/fsm_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright 2024 Camptocamp SA (https://www.camptocamp.com).
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, models


class FSMOrder(models.Model):
_inherit = "fsm.order"

@api.model_create_multi
def create(self, vals_list):
# OVERRIDE to apply the repair order template on the related repair order
records = super().create(vals_list)
records._apply_repair_order_template()
return records

def write(self, vals):
# OVERRIDE to apply the repair order template on the related repair order
res = super().write(vals)
if "template_id" in vals:
self._apply_repair_order_template()
return res

def _onchange_template_id(self):
res = super()._onchange_template_id()
self._apply_repair_order_template()
return res

def _apply_repair_order_template(self):
"""Apply the Repair Order Template on the related repair order"""
for rec in self:
if (
rec.repair_id
and rec.repair_id.state == "draft"
and rec.template_id.repair_order_template_id
):
rec.repair_id.repair_order_template_id = (
rec.template_id.repair_order_template_id
)
rec.repair_id._onchange_repair_order_template_id()
15 changes: 15 additions & 0 deletions fieldservice_repair_order_template/models/fsm_template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2024 Camptocamp SA (https://www.camptocamp.com).
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class FSMTemplate(models.Model):
_inherit = "fsm.template"

repair_order_template_id = fields.Many2one(
comodel_name="repair.order.template",
string="Repair Order Template",
help="If set, this template will be used to create the repair order.",
)
type_internal = fields.Selection(related="type_id.internal_type")
3 changes: 3 additions & 0 deletions fieldservice_repair_order_template/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_repair_order_template/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Go to **Field Service > Master Data > Templates** and select the desired
**Repair Order Template**.

3 changes: 3 additions & 0 deletions fieldservice_repair_order_template/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- [Camptocamp](https://camptocamp.com/):

- Iván Todorovich \<<[email protected]>\>
2 changes: 2 additions & 0 deletions fieldservice_repair_order_template/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Use the **Repair Order Templates** to pre-fill some fields on the generated
repair orders.
Loading
Loading