Skip to content

Commit

Permalink
[17.0][ADD] fieldservice_equipment_stock_return: add return order type
Browse files Browse the repository at this point in the history
  • Loading branch information
ilo committed Oct 29, 2024
1 parent 0f9586a commit 8dfd9eb
Show file tree
Hide file tree
Showing 22 changed files with 1,104 additions and 0 deletions.
115 changes: 115 additions & 0 deletions fieldservice_equipment_stock_return/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
======================================
Field Service - Stock Equipment Return
======================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:ccef108ff488fd2820ce9403b90512a866de4e4edaa606f7f03418b70520b741
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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_equipment_stock_return
: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_equipment_stock_return
: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 return FSM equipments creating a new picking.

**Table of contents**

.. contents::
:local:

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

Check ``Field Service - Stock Equipment`` module configuration.

To configure this module, you need to:

- Go to Field Service > Configuration > Order Types
- Check if you have at least one ``return`` order type
- Set the ``Picking Type`` linked to the ``return`` order type

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_equipment_stock_return%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
* Italo LOPES

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

- Italo LOPES <[email protected]>

Other credits
-------------

The development of this module has been financially supported by:

- Camptocamp SA <https://camptocamp.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.

.. |maintainer-brian10048| image:: https://github.com/brian10048.png?size=40px
:target: https://github.com/brian10048
:alt: brian10048
.. |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-smangukiya| image:: https://github.com/smangukiya.png?size=40px
:target: https://github.com/smangukiya
:alt: smangukiya
.. |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-brian10048| |maintainer-wolfhall| |maintainer-max3903| |maintainer-smangukiya| |maintainer-imlopes|

This module is part of the `OCA/field-service <https://github.com/OCA/field-service/tree/17.0/fieldservice_equipment_stock_return>`_ 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_equipment_stock_return/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
30 changes: 30 additions & 0 deletions fieldservice_equipment_stock_return/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# 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 - Stock Equipment Return",
"summary": "Integrate return orders for field service equipments",
"version": "17.0.1.0.0",
"category": "Field Service",
"author": "Camptocamp, " "Italo LOPES, " "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/field-service",
"depends": [
"fieldservice_equipment_stock",
],
"data": [
"data/fsm_order_type.xml",
"views/fsm_equipment.xml",
"views/fsm_order_view.xml",
"views/fsm_order_type_view.xml",
],
"license": "AGPL-3",
"development_status": "Beta",
"maintainers": [
"brian10048",
"wolfhall",
"max3903",
"smangukiya",
"imlopes",
],
}
9 changes: 9 additions & 0 deletions fieldservice_equipment_stock_return/data/fsm_order_type.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1">

<record id="fsm_order_type_return" model="fsm.order.type">
<field name="name">Return</field>
<field name="internal_type">return</field>
</record>

</odoo>
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * fieldservice_equipment_stock_return
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 17.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-10-29 14:22+0000\n"
"PO-Revision-Date: 2024-10-29 14:22+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: fieldservice_equipment_stock_return
#. odoo-python
#: code:addons/fieldservice_equipment_stock_return/models/fsm_order.py:0
#, python-format
msgid ""
"Cannot create a return order because order type does not have a current "
"Picking Type."
msgstr ""

#. module: fieldservice_equipment_stock_return
#. odoo-python
#: code:addons/fieldservice_equipment_stock_return/models/fsm_order.py:0
#, python-format
msgid "Cannot create return order without an equipment."
msgstr ""

#. module: fieldservice_equipment_stock_return
#: model_terms:ir.ui.view,arch_db:fieldservice_equipment_stock_return.fsm_equipment_form_view_stock
msgid "Create Return"
msgstr ""

#. module: fieldservice_equipment_stock_return
#: model:ir.model,name:fieldservice_equipment_stock_return.model_fsm_equipment
msgid "Field Service Equipment"
msgstr ""

#. module: fieldservice_equipment_stock_return
#: model:ir.model,name:fieldservice_equipment_stock_return.model_fsm_order
msgid "Field Service Order"
msgstr ""

#. module: fieldservice_equipment_stock_return
#: model:ir.model,name:fieldservice_equipment_stock_return.model_fsm_order_type
msgid "Field Service Order Type"
msgstr ""

#. module: fieldservice_equipment_stock_return
#. odoo-python
#: code:addons/fieldservice_equipment_stock_return/models/fsm_order.py:0
#, python-format
msgid "Impossible to find the equipment current location."
msgstr ""

#. module: fieldservice_equipment_stock_return
#: model:ir.model.fields,field_description:fieldservice_equipment_stock_return.field_fsm_order_type__internal_type
msgid "Internal Type"
msgstr ""

#. module: fieldservice_equipment_stock_return
#. odoo-python
#: code:addons/fieldservice_equipment_stock_return/models/fsm_equipment.py:0
#, python-format
msgid "No return order type found."
msgstr ""

#. module: fieldservice_equipment_stock_return
#: model:ir.model.fields,field_description:fieldservice_equipment_stock_return.field_fsm_order_type__picking_type_id
msgid "Picking Type"
msgstr ""

#. module: fieldservice_equipment_stock_return
#: model:ir.model.fields.selection,name:fieldservice_equipment_stock_return.selection__fsm_order_type__internal_type__return
msgid "Return"
msgstr ""
81 changes: 81 additions & 0 deletions fieldservice_equipment_stock_return/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * fieldservice_equipment_stock_return
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 17.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-10-29 14:22+0000\n"
"PO-Revision-Date: 2024-10-29 14:22+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: fieldservice_equipment_stock_return
#. odoo-python
#: code:addons/fieldservice_equipment_stock_return/models/fsm_order.py:0
#, python-format
msgid ""
"Cannot create a return order because order type does not have a current "
"Picking Type."
msgstr "Impossible de créer une commande de retour car le type choisie n'a pas de Type de Picking définie."

#. module: fieldservice_equipment_stock_return
#. odoo-python
#: code:addons/fieldservice_equipment_stock_return/models/fsm_order.py:0
#, python-format
msgid "Cannot create return order without an equipment."
msgstr "Impossible de créer une commande de retour sans équipement."

#. module: fieldservice_equipment_stock_return
#: model_terms:ir.ui.view,arch_db:fieldservice_equipment_stock_return.fsm_equipment_form_view_stock
msgid "Create Return"
msgstr "Créer un retour"

#. module: fieldservice_equipment_stock_return
#: model:ir.model,name:fieldservice_equipment_stock_return.model_fsm_equipment
msgid "Field Service Equipment"
msgstr ""

#. module: fieldservice_equipment_stock_return
#: model:ir.model,name:fieldservice_equipment_stock_return.model_fsm_order
msgid "Field Service Order"
msgstr ""

#. module: fieldservice_equipment_stock_return
#: model:ir.model,name:fieldservice_equipment_stock_return.model_fsm_order_type
msgid "Field Service Order Type"
msgstr ""

#. module: fieldservice_equipment_stock_return
#. odoo-python
#: code:addons/fieldservice_equipment_stock_return/models/fsm_order.py:0
#, python-format
msgid "Impossible to find the equipment current location."
msgstr "Impossible de trouver l'emplacement actuel de l'équipement."

#. module: fieldservice_equipment_stock_return
#: model:ir.model.fields,field_description:fieldservice_equipment_stock_return.field_fsm_order_type__internal_type
msgid "Internal Type"
msgstr ""

#. module: fieldservice_equipment_stock_return
#. odoo-python
#: code:addons/fieldservice_equipment_stock_return/models/fsm_equipment.py:0
#, python-format
msgid "No return order type found."
msgstr "Aucun type de commande avec un type interne de retour trouvé."

#. module: fieldservice_equipment_stock_return
#: model:ir.model.fields,field_description:fieldservice_equipment_stock_return.field_fsm_order_type__picking_type_id
msgid "Picking Type"
msgstr ""

#. module: fieldservice_equipment_stock_return
#: model:ir.model.fields.selection,name:fieldservice_equipment_stock_return.selection__fsm_order_type__internal_type__return
msgid "Return"
msgstr "Retour"
5 changes: 5 additions & 0 deletions fieldservice_equipment_stock_return/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from . import (
fsm_equipment,
fsm_order,
fsm_order_type,
)
33 changes: 33 additions & 0 deletions fieldservice_equipment_stock_return/models/fsm_equipment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# 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
from odoo.exceptions import ValidationError


class FSMEquipment(models.Model):
_inherit = "fsm.equipment"

def create_equipment_order_return(self):
self.ensure_one()
order_type = self.env.ref(
"fieldservice_equipment_stock_return.fsm_order_type_return",
raise_if_not_found=False,
)
if not order_type:
order_type = self.env["fsm.order.type"].search(
[("internal_type", "=", "return")], limit=1
)
if not order_type:
raise ValidationError(_("No return order type found."))
return {

Check warning on line 24 in fieldservice_equipment_stock_return/models/fsm_equipment.py

View check run for this annotation

Codecov / codecov/patch

fieldservice_equipment_stock_return/models/fsm_equipment.py#L24

Added line #L24 was not covered by tests
"name": "Return Equipment",
"type": "ir.actions.act_window",
"res_model": "fsm.order",
"view_mode": "form",
"context": {
"default_equipment_id": self.id,
"default_type": order_type and order_type.id or False,
},
}
Loading

0 comments on commit 8dfd9eb

Please sign in to comment.