diff --git a/fieldservice_fleet/README.rst b/fieldservice_fleet/README.rst new file mode 100644 index 0000000000..800c72b5ce --- /dev/null +++ b/fieldservice_fleet/README.rst @@ -0,0 +1,145 @@ +=================== +Field Service Fleet +=================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/12.0/fieldservice_fleet + :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-12-0/field-service-12-0-fieldservice_fleet + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/264/12.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows you to link the vehicles and workers of Field Service with vehicles and drivers of Fleet. + +Beware that the Fleet module can have more vehicles than the FSM one (not all vehicles of the company are used for Field Service work). + +**Table of contents** + +.. contents:: + :local: + +Installation +============ + +To install Field Service and have the mapping features, you need to install GeoEngine. + +Please refer to the installation instructions available at: +https://github.com/OCA/geospatial/tree/12.0/base_geoengine + +Configuration +============= + +Upon installation, any existing FSM Vehicles will have Fleet vehicles created for them. + +Go to Fleet and review the vehicles created from the existing FSM vehicles + +* Update the vehicle model as needed +* Update the odometer unit which is set to kilometers by default + +Usage +===== + +To use this module, you need to: + +Fleet + + * Go to Fleet + * Create or select a vehicle + * From Action menu, choose Convert to FSM Vehicle + * A new FSM Vehicle will be created linked to this Fleet Vehicle + +Field Service + + * Go to Field Service > Master Data > Vehicles + * Select or create a vehicle. + * Link to a Fleet Vehicle by assigining one to the vehicle details + +Changing the Fleet vehicle driver sets the FSM Vehicle worker +Changing the FSM Vehicle worker sets the Fleet Vehicle driver + +Known issues / Roadmap +====================== + +The roadmap of the Field Service application is documented on +`Github `_. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Brian McMaster +* Open Source Integrators + +Contributors +~~~~~~~~~~~~ + +* Wolfgang Hall +* Maxime Chambreuil +* Brian McMaster + +Other credits +~~~~~~~~~~~~~ + +The development of this module has been financially supported by: + +* Open Source Integrators +* McMaster Lawn & Pest Services + +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 + +Current `maintainers `__: + +|maintainer-wolfhall| |maintainer-max3903| |maintainer-brian10048| + +This module is part of the `OCA/field-service `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/fieldservice_fleet/__init__.py b/fieldservice_fleet/__init__.py new file mode 100644 index 0000000000..05208c5649 --- /dev/null +++ b/fieldservice_fleet/__init__.py @@ -0,0 +1,7 @@ +# Copyright (C) 2019 Open Source Integrators +# Copyright (C) 2019 Brian McMaster +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import models +from . import wizard +from .hooks import pre_init_hook diff --git a/fieldservice_fleet/__manifest__.py b/fieldservice_fleet/__manifest__.py new file mode 100644 index 0000000000..9a1bfc5de9 --- /dev/null +++ b/fieldservice_fleet/__manifest__.py @@ -0,0 +1,25 @@ +# Copyright (C) 2019 Open Source Integrators +# Copyright (C) 2019 Brian McMaster +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Field Service Fleet", + "summary": "Link Field Service vehicles with Odoo Fleet", + "version": "13.0.1.0.0", + "category": "Field Service", + "author": "Brian McMaster, " + "Open Source Integrators, " + "Odoo Community Association (OCA)", + "website": "https://github.com/OCA/field-service", + "depends": ["fieldservice_vehicle", "fleet"], + "data": [ + "views/fsm_vehicle.xml", + "views/fleet_vehicle.xml", + "wizard/fsm_fleet_wizard.xml", + ], + "license": "AGPL-3", + "development_status": "Beta", + "maintainers": ["wolfhall", "max3903", "brian10048"], + "pre_init_hook": "pre_init_hook", + "installable": True, +} diff --git a/fieldservice_fleet/hooks.py b/fieldservice_fleet/hooks.py new file mode 100644 index 0000000000..5bf726e1c5 --- /dev/null +++ b/fieldservice_fleet/hooks.py @@ -0,0 +1,65 @@ +# Copyright (C) 2019 Brian McMaster +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import SUPERUSER_ID, api + + +def pre_init_hook(cr): + # Check for existing fsm vehicles + cr.execute("SELECT * FROM fsm_vehicle") + vehicles = [] + vehicles = cr.dictfetchall() + if vehicles: + # Add new columns to hold values + cr.execute("ALTER TABLE fsm_vehicle ADD fleet_vehicle_id INT;") + cr.execute("ALTER TABLE fleet_vehicle ADD is_fsm_vehicle BOOLEAN;") + + # Get a fleet vehicle model to set on the new Fleet vehicle(s) + env = api.Environment(cr, SUPERUSER_ID, {}) + model_id = env["fleet.vehicle.model"].search([], limit=1).id + + # Create a new Fleet vehicle for each FSM vehicle + for veh in vehicles: + # Get the FSM worker to set as the Fleet driver + fsm_person_id = veh.get("person_id", False) + driver_id = False + if fsm_person_id: + driver_id = env["fsm.person"].browse(fsm_person_id).partner_id.id + + cr.execute( + """ + INSERT INTO fleet_vehicle ( + name, + model_id, + driver_id, + is_fsm_vehicle, + odometer_unit, + active) + VALUES ( + %s, + %s, + %s, + True, + 'kilometers', + True);""", + (veh.get("name"), model_id, driver_id), + ) + + # Set this new Fleet vehicle on the existing FSM vehicle + cr.execute( + """ + SELECT id + FROM fleet_vehicle + ORDER BY id desc + LIMIT 1 + """ + ) + fleet = cr.dictfetchone() + + cr.execute( + """ + UPDATE fsm_vehicle + SET fleet_vehicle_id = %s + WHERE id = %s;""", + (fleet.get("id"), veh.get("id")), + ) diff --git a/fieldservice_fleet/i18n/es.po b/fieldservice_fleet/i18n/es.po new file mode 100644 index 0000000000..668d053fa9 --- /dev/null +++ b/fieldservice_fleet/i18n/es.po @@ -0,0 +1,117 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * fieldservice_fleet +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2020-01-03 05:13+0000\n" +"Last-Translator: Nelson Ram??rez S??nchez \n" +"Language-Team: none\n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 3.10\n" + +#. module: fieldservice_fleet +#: code:addons/fieldservice_fleet/wizard/fsm_fleet_wizard.py:39 +#, python-format +msgid "A Field Service Vehicle related to that Fleet Vehicle already exists." +msgstr "" +"Ya existe un veh??culo de servicio de campo relacionado con ese veh??culo de " +"la flota." + +#. module: fieldservice_fleet +#: model_terms:ir.ui.view,arch_db:fieldservice_fleet.vehicle_wizard_view +msgid "Cancel" +msgstr "" + +#. module: fieldservice_fleet +#: model_terms:ir.ui.view,arch_db:fieldservice_fleet.vehicle_wizard_view +msgid "Convert" +msgstr "" + +#. module: fieldservice_fleet +#: model_terms:ir.ui.view,arch_db:fieldservice_fleet.vehicle_wizard_view +msgid "Convert this vehicle record into a Field Service Vehicle." +msgstr "" +"Convierta este registro de veh??culo en un veh??culo de servicio de campo." + +#. module: fieldservice_fleet +#: model:ir.actions.act_window,name:fieldservice_fleet.vehicle_fsm_action +msgid "Convert to FSM Vehicle" +msgstr "Convertir a Veh??culo FSM" + +#. module: fieldservice_fleet +#: model_terms:ir.ui.view,arch_db:fieldservice_fleet.vehicle_wizard_view +msgid "Convert to a Field Service Vehicle" +msgstr "Convertir a un veh??culo de servicio de campo" + +#. module: fieldservice_fleet +#: model:ir.model.fields,field_description:fieldservice_fleet.field_fsm_fleet_wizard__create_uid +msgid "Created by" +msgstr "" + +#. module: fieldservice_fleet +#: model:ir.model.fields,field_description:fieldservice_fleet.field_fsm_fleet_wizard__create_date +msgid "Created on" +msgstr "" + +#. module: fieldservice_fleet +#: model:ir.model.fields,field_description:fieldservice_fleet.field_fsm_fleet_wizard__display_name +msgid "Display Name" +msgstr "Nombre para Mostrar" + +#. module: fieldservice_fleet +#: model:ir.model,name:fieldservice_fleet.model_fsm_fleet_wizard +msgid "FSM Fleet Vehicle Conversion" +msgstr "Conversi??n de veh??culos de flota FSM" + +#. module: fieldservice_fleet +#: sql_constraint:fsm.vehicle:0 +msgid "FSM vehicle can only be linked to one fleet vehicle" +msgstr "El veh??culo FSM solo se puede vincular a un veh??culo de flota" + +#. module: fieldservice_fleet +#: model:ir.model,name:fieldservice_fleet.model_fsm_vehicle +msgid "Field Service Vehicle" +msgstr "" + +#. module: fieldservice_fleet +#: model:ir.model.fields,field_description:fieldservice_fleet.field_fsm_fleet_wizard__id +msgid "ID" +msgstr "" + +#. module: fieldservice_fleet +#: model:ir.model.fields,field_description:fieldservice_fleet.field_fleet_vehicle__is_fsm_vehicle +#: model:ir.model.fields,field_description:fieldservice_fleet.field_fsm_vehicle__is_fsm_vehicle +msgid "Is used for Field Service?" +msgstr "??Se utiliza para servicio de campo?" + +#. module: fieldservice_fleet +#: model:ir.model.fields,field_description:fieldservice_fleet.field_fsm_fleet_wizard____last_update +msgid "Last Modified on" +msgstr "" + +#. module: fieldservice_fleet +#: model:ir.model.fields,field_description:fieldservice_fleet.field_fsm_fleet_wizard__write_uid +msgid "Last Updated by" +msgstr "" + +#. module: fieldservice_fleet +#: model:ir.model.fields,field_description:fieldservice_fleet.field_fsm_fleet_wizard__write_date +msgid "Last Updated on" +msgstr "" + +#. module: fieldservice_fleet +#: model:ir.model,name:fieldservice_fleet.model_fleet_vehicle +msgid "Vehicle" +msgstr "" + +#. module: fieldservice_fleet +#: model:ir.model.fields,field_description:fieldservice_fleet.field_fsm_vehicle__fleet_vehicle_id +msgid "Vehicle Details" +msgstr "Detalles del Veh??culo" diff --git a/fieldservice_fleet/i18n/es_CL.po b/fieldservice_fleet/i18n/es_CL.po new file mode 100644 index 0000000000..52fba19780 --- /dev/null +++ b/fieldservice_fleet/i18n/es_CL.po @@ -0,0 +1,117 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * fieldservice_fleet +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2020-01-03 05:13+0000\n" +"Last-Translator: Nelson Ram??rez S??nchez \n" +"Language-Team: none\n" +"Language: es_CL\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 3.10\n" + +#. module: fieldservice_fleet +#: code:addons/fieldservice_fleet/wizard/fsm_fleet_wizard.py:39 +#, python-format +msgid "A Field Service Vehicle related to that Fleet Vehicle already exists." +msgstr "" +"Ya existe un veh??culo de servicio de campo relacionado con ese veh??culo de " +"la flota." + +#. module: fieldservice_fleet +#: model_terms:ir.ui.view,arch_db:fieldservice_fleet.vehicle_wizard_view +msgid "Cancel" +msgstr "" + +#. module: fieldservice_fleet +#: model_terms:ir.ui.view,arch_db:fieldservice_fleet.vehicle_wizard_view +msgid "Convert" +msgstr "" + +#. module: fieldservice_fleet +#: model_terms:ir.ui.view,arch_db:fieldservice_fleet.vehicle_wizard_view +msgid "Convert this vehicle record into a Field Service Vehicle." +msgstr "" +"Convierta este registro de veh??culo en un veh??culo de servicio de campo." + +#. module: fieldservice_fleet +#: model:ir.actions.act_window,name:fieldservice_fleet.vehicle_fsm_action +msgid "Convert to FSM Vehicle" +msgstr "Convertir a Veh??culo FSM" + +#. module: fieldservice_fleet +#: model_terms:ir.ui.view,arch_db:fieldservice_fleet.vehicle_wizard_view +msgid "Convert to a Field Service Vehicle" +msgstr "Convertir a un veh??culo de servicio de campo" + +#. module: fieldservice_fleet +#: model:ir.model.fields,field_description:fieldservice_fleet.field_fsm_fleet_wizard__create_uid +msgid "Created by" +msgstr "" + +#. module: fieldservice_fleet +#: model:ir.model.fields,field_description:fieldservice_fleet.field_fsm_fleet_wizard__create_date +msgid "Created on" +msgstr "" + +#. module: fieldservice_fleet +#: model:ir.model.fields,field_description:fieldservice_fleet.field_fsm_fleet_wizard__display_name +msgid "Display Name" +msgstr "Nombre para Mostrar" + +#. module: fieldservice_fleet +#: model:ir.model,name:fieldservice_fleet.model_fsm_fleet_wizard +msgid "FSM Fleet Vehicle Conversion" +msgstr "Conversi??n de veh??culos de flota FSM" + +#. module: fieldservice_fleet +#: sql_constraint:fsm.vehicle:0 +msgid "FSM vehicle can only be linked to one fleet vehicle" +msgstr "El veh??culo FSM solo se puede vincular a un veh??culo de flota" + +#. module: fieldservice_fleet +#: model:ir.model,name:fieldservice_fleet.model_fsm_vehicle +msgid "Field Service Vehicle" +msgstr "" + +#. module: fieldservice_fleet +#: model:ir.model.fields,field_description:fieldservice_fleet.field_fsm_fleet_wizard__id +msgid "ID" +msgstr "" + +#. module: fieldservice_fleet +#: model:ir.model.fields,field_description:fieldservice_fleet.field_fleet_vehicle__is_fsm_vehicle +#: model:ir.model.fields,field_description:fieldservice_fleet.field_fsm_vehicle__is_fsm_vehicle +msgid "Is used for Field Service?" +msgstr "??Se utiliza para servicio de campo?" + +#. module: fieldservice_fleet +#: model:ir.model.fields,field_description:fieldservice_fleet.field_fsm_fleet_wizard____last_update +msgid "Last Modified on" +msgstr "" + +#. module: fieldservice_fleet +#: model:ir.model.fields,field_description:fieldservice_fleet.field_fsm_fleet_wizard__write_uid +msgid "Last Updated by" +msgstr "" + +#. module: fieldservice_fleet +#: model:ir.model.fields,field_description:fieldservice_fleet.field_fsm_fleet_wizard__write_date +msgid "Last Updated on" +msgstr "" + +#. module: fieldservice_fleet +#: model:ir.model,name:fieldservice_fleet.model_fleet_vehicle +msgid "Vehicle" +msgstr "" + +#. module: fieldservice_fleet +#: model:ir.model.fields,field_description:fieldservice_fleet.field_fsm_vehicle__fleet_vehicle_id +msgid "Vehicle Details" +msgstr "Detalles del Veh??culo" diff --git a/fieldservice_fleet/i18n/fieldservice_fleet.pot b/fieldservice_fleet/i18n/fieldservice_fleet.pot new file mode 100644 index 0000000000..054c4c31dd --- /dev/null +++ b/fieldservice_fleet/i18n/fieldservice_fleet.pot @@ -0,0 +1,112 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * fieldservice_fleet +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \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_fleet +#: code:addons/fieldservice_fleet/wizard/fsm_fleet_wizard.py:39 +#, python-format +msgid "A Field Service Vehicle related to that Fleet Vehicle already exists." +msgstr "" + +#. module: fieldservice_fleet +#: model_terms:ir.ui.view,arch_db:fieldservice_fleet.vehicle_wizard_view +msgid "Cancel" +msgstr "" + +#. module: fieldservice_fleet +#: model_terms:ir.ui.view,arch_db:fieldservice_fleet.vehicle_wizard_view +msgid "Convert" +msgstr "" + +#. module: fieldservice_fleet +#: model_terms:ir.ui.view,arch_db:fieldservice_fleet.vehicle_wizard_view +msgid "Convert this vehicle record into a Field Service Vehicle." +msgstr "" + +#. module: fieldservice_fleet +#: model:ir.actions.act_window,name:fieldservice_fleet.vehicle_fsm_action +msgid "Convert to FSM Vehicle" +msgstr "" + +#. module: fieldservice_fleet +#: model_terms:ir.ui.view,arch_db:fieldservice_fleet.vehicle_wizard_view +msgid "Convert to a Field Service Vehicle" +msgstr "" + +#. module: fieldservice_fleet +#: model:ir.model.fields,field_description:fieldservice_fleet.field_fsm_fleet_wizard__create_uid +msgid "Created by" +msgstr "" + +#. module: fieldservice_fleet +#: model:ir.model.fields,field_description:fieldservice_fleet.field_fsm_fleet_wizard__create_date +msgid "Created on" +msgstr "" + +#. module: fieldservice_fleet +#: model:ir.model.fields,field_description:fieldservice_fleet.field_fsm_fleet_wizard__display_name +msgid "Display Name" +msgstr "" + +#. module: fieldservice_fleet +#: model:ir.model,name:fieldservice_fleet.model_fsm_fleet_wizard +msgid "FSM Fleet Vehicle Conversion" +msgstr "" + +#. module: fieldservice_fleet +#: sql_constraint:fsm.vehicle:0 +msgid "FSM vehicle can only be linked to one fleet vehicle" +msgstr "" + +#. module: fieldservice_fleet +#: model:ir.model,name:fieldservice_fleet.model_fsm_vehicle +msgid "Field Service Vehicle" +msgstr "" + +#. module: fieldservice_fleet +#: model:ir.model.fields,field_description:fieldservice_fleet.field_fsm_fleet_wizard__id +msgid "ID" +msgstr "" + +#. module: fieldservice_fleet +#: model:ir.model.fields,field_description:fieldservice_fleet.field_fleet_vehicle__is_fsm_vehicle +#: model:ir.model.fields,field_description:fieldservice_fleet.field_fsm_vehicle__is_fsm_vehicle +msgid "Is used for Field Service?" +msgstr "" + +#. module: fieldservice_fleet +#: model:ir.model.fields,field_description:fieldservice_fleet.field_fsm_fleet_wizard____last_update +msgid "Last Modified on" +msgstr "" + +#. module: fieldservice_fleet +#: model:ir.model.fields,field_description:fieldservice_fleet.field_fsm_fleet_wizard__write_uid +msgid "Last Updated by" +msgstr "" + +#. module: fieldservice_fleet +#: model:ir.model.fields,field_description:fieldservice_fleet.field_fsm_fleet_wizard__write_date +msgid "Last Updated on" +msgstr "" + +#. module: fieldservice_fleet +#: model:ir.model,name:fieldservice_fleet.model_fleet_vehicle +msgid "Vehicle" +msgstr "" + +#. module: fieldservice_fleet +#: model:ir.model.fields,field_description:fieldservice_fleet.field_fsm_vehicle__fleet_vehicle_id +msgid "Vehicle Details" +msgstr "" + diff --git a/fieldservice_fleet/i18n/pt_BR.po b/fieldservice_fleet/i18n/pt_BR.po new file mode 100644 index 0000000000..4489c13766 --- /dev/null +++ b/fieldservice_fleet/i18n/pt_BR.po @@ -0,0 +1,117 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * fieldservice_fleet +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2020-06-17 16:19+0000\n" +"Last-Translator: Fernando Colus \n" +"Language-Team: none\n" +"Language: pt_BR\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n > 1;\n" +"X-Generator: Weblate 3.10\n" + +#. module: fieldservice_fleet +#: code:addons/fieldservice_fleet/wizard/fsm_fleet_wizard.py:39 +#, python-format +msgid "A Field Service Vehicle related to that Fleet Vehicle already exists." +msgstr "" +"Um Ve??culo de Servi??o de Campo relacionado a esse Ve??culo de Frota j?? existe." + +#. module: fieldservice_fleet +#: model_terms:ir.ui.view,arch_db:fieldservice_fleet.vehicle_wizard_view +msgid "Cancel" +msgstr "Cancelar" + +#. module: fieldservice_fleet +#: model_terms:ir.ui.view,arch_db:fieldservice_fleet.vehicle_wizard_view +msgid "Convert" +msgstr "Converter" + +#. module: fieldservice_fleet +#: model_terms:ir.ui.view,arch_db:fieldservice_fleet.vehicle_wizard_view +msgid "Convert this vehicle record into a Field Service Vehicle." +msgstr "Converta este registro do ve??culo em um Ve??culo de Servi??o de Campo." + +#. module: fieldservice_fleet +#: model:ir.actions.act_window,name:fieldservice_fleet.vehicle_fsm_action +msgid "Convert to FSM Vehicle" +msgstr "Converter em ve??culo FSM" + +#. module: fieldservice_fleet +#: model_terms:ir.ui.view,arch_db:fieldservice_fleet.vehicle_wizard_view +msgid "Convert to a Field Service Vehicle" +msgstr "Converter em um Ve??culo de Servi??o de Campo" + +#. module: fieldservice_fleet +#: model:ir.model.fields,field_description:fieldservice_fleet.field_fsm_fleet_wizard__create_uid +msgid "Created by" +msgstr "Criado por" + +#. module: fieldservice_fleet +#: model:ir.model.fields,field_description:fieldservice_fleet.field_fsm_fleet_wizard__create_date +msgid "Created on" +msgstr "Criado em" + +#. module: fieldservice_fleet +#: model:ir.model.fields,field_description:fieldservice_fleet.field_fsm_fleet_wizard__display_name +msgid "Display Name" +msgstr "Nome Exibido" + +#. module: fieldservice_fleet +#: model:ir.model,name:fieldservice_fleet.model_fsm_fleet_wizard +msgid "FSM Fleet Vehicle Conversion" +msgstr "Convers??o de ve??culo de frota FSM (Field Services Management)" + +#. module: fieldservice_fleet +#: sql_constraint:fsm.vehicle:0 +msgid "FSM vehicle can only be linked to one fleet vehicle" +msgstr "" +"O ve??culo no FSM (Field Services Management) s?? pode ser vinculado a um " +"??nico ve??culo da frota" + +#. module: fieldservice_fleet +#: model:ir.model,name:fieldservice_fleet.model_fsm_vehicle +msgid "Field Service Vehicle" +msgstr "Ve??culo de Servi??o de Campo" + +#. module: fieldservice_fleet +#: model:ir.model.fields,field_description:fieldservice_fleet.field_fsm_fleet_wizard__id +msgid "ID" +msgstr "ID" + +#. module: fieldservice_fleet +#: model:ir.model.fields,field_description:fieldservice_fleet.field_fleet_vehicle__is_fsm_vehicle +#: model:ir.model.fields,field_description:fieldservice_fleet.field_fsm_vehicle__is_fsm_vehicle +msgid "Is used for Field Service?" +msgstr "?? usado para Servi??o de Campo?" + +#. module: fieldservice_fleet +#: model:ir.model.fields,field_description:fieldservice_fleet.field_fsm_fleet_wizard____last_update +msgid "Last Modified on" +msgstr "??ltima Modifica????o Feita em" + +#. module: fieldservice_fleet +#: model:ir.model.fields,field_description:fieldservice_fleet.field_fsm_fleet_wizard__write_uid +msgid "Last Updated by" +msgstr "??ltima Atualiza????o por" + +#. module: fieldservice_fleet +#: model:ir.model.fields,field_description:fieldservice_fleet.field_fsm_fleet_wizard__write_date +msgid "Last Updated on" +msgstr "??ltima Atualiza????o em" + +#. module: fieldservice_fleet +#: model:ir.model,name:fieldservice_fleet.model_fleet_vehicle +msgid "Vehicle" +msgstr "Ve??culo" + +#. module: fieldservice_fleet +#: model:ir.model.fields,field_description:fieldservice_fleet.field_fsm_vehicle__fleet_vehicle_id +msgid "Vehicle Details" +msgstr "Detalhes do Ve??culo" diff --git a/fieldservice_fleet/models/__init__.py b/fieldservice_fleet/models/__init__.py new file mode 100644 index 0000000000..9c4a2db24b --- /dev/null +++ b/fieldservice_fleet/models/__init__.py @@ -0,0 +1,8 @@ +# Copyright (C) 2019 Open Source Integrators +# Copyright (C) 2019 Brian McMaster +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import ( + fsm_vehicle, + fleet_vehicle, +) diff --git a/fieldservice_fleet/models/fleet_vehicle.py b/fieldservice_fleet/models/fleet_vehicle.py new file mode 100644 index 0000000000..24038b961c --- /dev/null +++ b/fieldservice_fleet/models/fleet_vehicle.py @@ -0,0 +1,30 @@ +# Copyright (C) 2019 Open Source Integrators +# Copyright (C) 2019 Brian McMaster +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class FleetVehicle(models.Model): + _inherit = "fleet.vehicle" + + is_fsm_vehicle = fields.Boolean(string="Is used for Field Service?") + + def set_fsm_driver(self): + self.ensure_one() + if self.driver_id and self.is_fsm_vehicle: + driver_partner = self.driver_id + fsm_worker = self.env["fsm.person"].search( + [("partner_id", "=", driver_partner.id)] + ) + if not fsm_worker: + # Create FSM worker + fsm_worker = self.env["fsm.person"].create( + {"partner_id": driver_partner.id} + ) + driver_partner.write({"fsm_person": True}) + fsm_vehicle = self.env["fsm.vehicle"].search( + [("fleet_vehicle_id", "=", self.id)] + ) + # Assign the worker to the FSM vehicle + fsm_vehicle.person_id = fsm_worker diff --git a/fieldservice_fleet/models/fsm_vehicle.py b/fieldservice_fleet/models/fsm_vehicle.py new file mode 100644 index 0000000000..f2ecee67a1 --- /dev/null +++ b/fieldservice_fleet/models/fsm_vehicle.py @@ -0,0 +1,44 @@ +# Copyright (C) 2019 Open Source Integrators +# Copyright (C) 2019 Brian McMaster +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class FSMVehicle(models.Model): + _inherit = "fsm.vehicle" + _inherits = {"fleet.vehicle": "fleet_vehicle_id"} + + fleet_vehicle_id = fields.Many2one( + "fleet.vehicle", string="Vehicle Details", required=True, ondelete="restrict", + ) + + _sql_constraints = [ + ( + "fsm_vehicle_fleet_uniq", + "unique(id,fleet_vehicle_id)", + "FSM vehicle can only be linked to one fleet vehicle", + ) + ] + + @api.model + def create(self, vals): + fleet_id = vals.get("fleet_vehicle_id") + if fleet_id: + if vals.get("person_id", False): + vals["driver_id"] = vals.get("person_id") + vals["is_fsm_vehicle"] = True + return super().create(vals) + + def write(self, vals): + # update fsm.vehicle worker based on the fleet.vehicle driver + if "driver_id" in vals: + for vehicle in self: + if vehicle.is_fsm_vehicle: + vehicle.set_fsm_driver() + # update fleet.vehicle driver based on the fsm.vehicle worker + fsm_worker_id = vals.get("person_id", False) + if fsm_worker_id: + worker_partner = self.env["fsm.person"].browse(fsm_worker_id).partner_id + vals.update({"driver_id": worker_partner.id}) + return super().write(vals) diff --git a/fieldservice_fleet/readme/CONFIGURE.rst b/fieldservice_fleet/readme/CONFIGURE.rst new file mode 100644 index 0000000000..b47631caad --- /dev/null +++ b/fieldservice_fleet/readme/CONFIGURE.rst @@ -0,0 +1,6 @@ +Upon installation, any existing FSM Vehicles will have Fleet vehicles created for them. + +Go to Fleet and review the vehicles created from the existing FSM vehicles + +* Update the vehicle model as needed +* Update the odometer unit which is set to kilometers by default diff --git a/fieldservice_fleet/readme/CONTRIBUTORS.rst b/fieldservice_fleet/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000000..d43e0f1002 --- /dev/null +++ b/fieldservice_fleet/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* Wolfgang Hall +* Maxime Chambreuil +* Brian McMaster diff --git a/fieldservice_fleet/readme/CREDITS.rst b/fieldservice_fleet/readme/CREDITS.rst new file mode 100644 index 0000000000..367a40890a --- /dev/null +++ b/fieldservice_fleet/readme/CREDITS.rst @@ -0,0 +1,4 @@ +The development of this module has been financially supported by: + +* Open Source Integrators +* McMaster Lawn & Pest Services diff --git a/fieldservice_fleet/readme/DESCRIPTION.rst b/fieldservice_fleet/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..7f3c1d1097 --- /dev/null +++ b/fieldservice_fleet/readme/DESCRIPTION.rst @@ -0,0 +1,3 @@ +This module allows you to link the vehicles and workers of Field Service with vehicles and drivers of Fleet. + +Beware that the Fleet module can have more vehicles than the FSM one (not all vehicles of the company are used for Field Service work). diff --git a/fieldservice_fleet/readme/INSTALL.rst b/fieldservice_fleet/readme/INSTALL.rst new file mode 100644 index 0000000000..e5355c4b0f --- /dev/null +++ b/fieldservice_fleet/readme/INSTALL.rst @@ -0,0 +1,4 @@ +To install Field Service and have the mapping features, you need to install GeoEngine. + +Please refer to the installation instructions available at: +https://github.com/OCA/geospatial/tree/13.0/base_geoengine diff --git a/fieldservice_fleet/readme/ROADMAP.rst b/fieldservice_fleet/readme/ROADMAP.rst new file mode 100644 index 0000000000..f607015959 --- /dev/null +++ b/fieldservice_fleet/readme/ROADMAP.rst @@ -0,0 +1,2 @@ +The roadmap of the Field Service application is documented on +`Github `_. diff --git a/fieldservice_fleet/readme/USAGE.rst b/fieldservice_fleet/readme/USAGE.rst new file mode 100644 index 0000000000..505490587a --- /dev/null +++ b/fieldservice_fleet/readme/USAGE.rst @@ -0,0 +1,17 @@ +To use this module, you need to: + +Fleet + + * Go to Fleet + * Create or select a vehicle + * From Action menu, choose Convert to FSM Vehicle + * A new FSM Vehicle will be created linked to this Fleet Vehicle + +Field Service + + * Go to Field Service > Master Data > Vehicles + * Select or create a vehicle. + * Link to a Fleet Vehicle by assigining one to the vehicle details + +Changing the Fleet vehicle driver sets the FSM Vehicle worker +Changing the FSM Vehicle worker sets the Fleet Vehicle driver diff --git a/fieldservice_fleet/static/description/icon.png b/fieldservice_fleet/static/description/icon.png new file mode 100644 index 0000000000..955674d8f0 Binary files /dev/null and b/fieldservice_fleet/static/description/icon.png differ diff --git a/fieldservice_fleet/static/description/index.html b/fieldservice_fleet/static/description/index.html new file mode 100644 index 0000000000..ea9b423710 --- /dev/null +++ b/fieldservice_fleet/static/description/index.html @@ -0,0 +1,794 @@ + + + + + + + Field Service Fleet + + + +
+

Field Service Fleet

+ + +

+ Beta + License: AGPL-3 + OCA/field-service + Translate me on Weblate + Try me on Runbot +

+

+ This module allows you to link the vehicles and workers of Field Service with + vehicles and drivers of Fleet. +

+

+ Beware that the Fleet module can have more vehicles than the FSM one (not all + vehicles of the company are used for Field Service work). +

+

Table of contents

+
+ +
+
+

Installation

+

+ To install Field Service and have the mapping features, you need to install + GeoEngine. +

+

+ Please refer to the installation instructions available at: + https://github.com/OCA/geospatial/tree/12.0/base_geoengine +

+
+
+

Configuration

+

+ Upon installation, any existing FSM Vehicles will have Fleet vehicles created + for them. +

+

+ Go to Fleet and review the vehicles created from the existing FSM vehicles +

+
    +
  • Update the vehicle model as needed
  • +
  • Update the odometer unit which is set to kilometers by default
  • +
+
+
+

Usage

+

To use this module, you need to:

+

Fleet

+
+
    +
  • Go to Fleet
  • +
  • Create or select a vehicle
  • +
  • From Action menu, choose Convert to FSM Vehicle
  • +
  • A new FSM Vehicle will be created linked to this Fleet Vehicle
  • +
+
+

Field Service

+
+
    +
  • Go to Field Service > Master Data > Vehicles
  • +
  • Select or create a vehicle.
  • +
  • Link to a Fleet Vehicle by assigining one to the vehicle details
  • +
+
+

+ Changing the Fleet vehicle driver sets the FSM Vehicle worker Changing the FSM + Vehicle worker sets the Fleet Vehicle driver +

+
+
+

Known issues / Roadmap

+

+ The roadmap of the Field Service application is documented on + Github. +

+
+
+

Bug Tracker

+

+ Bugs are tracked on + GitHub Issues. In case of trouble, please check there if your issue has already been + reported. If you spotted it first, help us smashing it by providing a detailed + and welcomed + feedback. +

+

+ Do not contact contributors directly about support or help with technical + issues. +

+
+
+

Credits

+
+

Authors

+
    +
  • Brian McMaster
  • +
  • Open Source Integrators
  • +
+
+
+

Contributors

+ +
+
+

Other credits

+

The development of this module has been financially supported by:

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+ Odoo Community Association +

+ 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. +

+

+ Current + maintainers: +

+

+ wolfhall + max3903 + brian10048 +

+

+ This module is part of the + OCA/field-service + project on GitHub. +

+

+ You are welcome to contribute. To learn how please visit + https://odoo-community.org/page/Contribute. +

+
+
+
+ + diff --git a/fieldservice_fleet/tests/__init__.py b/fieldservice_fleet/tests/__init__.py new file mode 100644 index 0000000000..2c297e3189 --- /dev/null +++ b/fieldservice_fleet/tests/__init__.py @@ -0,0 +1,4 @@ +# Copyright (C) 2019 Brian McMaster +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import test_fsm_fleet_wizard diff --git a/fieldservice_fleet/tests/test_fsm_fleet_wizard.py b/fieldservice_fleet/tests/test_fsm_fleet_wizard.py new file mode 100644 index 0000000000..f20d054874 --- /dev/null +++ b/fieldservice_fleet/tests/test_fsm_fleet_wizard.py @@ -0,0 +1,56 @@ +# Copyright (C) 2019 Brian McMaster +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo.exceptions import UserError +from odoo.tests.common import TransactionCase + + +class TestFSMFleetWizard(TransactionCase): + def setUp(self): + super(TestFSMFleetWizard, self).setUp() + self.Wizard = self.env["fsm.fleet.wizard"] + self.fleet_vehicle_1 = self.env.ref("fleet.vehicle_1") + + def test_convert_vehicle(self): + # Convert a Fleet vehicle to FSM vehicle and link it + self.Wizard.action_convert_vehicle(self.fleet_vehicle_1) + + # Search FSM vehicle records linked to the test Fleet vehicle + fsm_vehicle = self.env["fsm.vehicle"].search( + [("fleet_vehicle_id", "=", self.fleet_vehicle_1.id)] + ) + + self.assertEqual( + len(fsm_vehicle), + 1, + """FSM Fleet Wizard: Did not find FSM vehicle + linked to Fleet vehicle""", + ) + self.assertEqual( + fsm_vehicle.name, + self.fleet_vehicle_1.name, + """FSM Fleet Wizard: FSM Vehicle and Fleet Vehicle + names do not match""", + ) + self.assertTrue( + self.fleet_vehicle_1.is_fsm_vehicle, + """FSM Fleet Wizard: Fleet vehicle boolean field + is_fsm_vehicle is False""", + ) + self.assertEqual( + fsm_vehicle.person_id.partner_id, + self.fleet_vehicle_1.driver_id, + """FSM Fleet Wizard: FSM vehicle driver is not same + as the Fleet vehicle driver""", + ) + + # Attempt to convert the Fleet vehicle again, but expect UserError + # because we already converted it + with self.assertRaises(UserError) as e: + self.Wizard.action_convert_vehicle(self.fleet_vehicle_1) + self.assertEqual( + e.exception.name, + "A Field Service Vehicle related to that" " Fleet Vehicle already exists.", + """FSM Fleet Wizard: UserError not thrown when converting + Fleet vehicle already linked to FSM Vehicle.""", + ) diff --git a/fieldservice_fleet/views/fleet_vehicle.xml b/fieldservice_fleet/views/fleet_vehicle.xml new file mode 100644 index 0000000000..be3d87fc7e --- /dev/null +++ b/fieldservice_fleet/views/fleet_vehicle.xml @@ -0,0 +1,12 @@ + + + fleet.vehicle.form.fsm + fleet.vehicle + + + + + + + + diff --git a/fieldservice_fleet/views/fsm_vehicle.xml b/fieldservice_fleet/views/fsm_vehicle.xml new file mode 100644 index 0000000000..caa1268dbd --- /dev/null +++ b/fieldservice_fleet/views/fsm_vehicle.xml @@ -0,0 +1,12 @@ + + + fsm.vehicle.form.fleet + fsm.vehicle + + + + + + + + diff --git a/fieldservice_fleet/wizard/__init__.py b/fieldservice_fleet/wizard/__init__.py new file mode 100644 index 0000000000..510adba741 --- /dev/null +++ b/fieldservice_fleet/wizard/__init__.py @@ -0,0 +1,5 @@ +# Copyright (C) 2019 Open Source Integrators +# Copyright (C) 2019 Brian McMaster +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import fsm_fleet_wizard diff --git a/fieldservice_fleet/wizard/fsm_fleet_wizard.py b/fieldservice_fleet/wizard/fsm_fleet_wizard.py new file mode 100644 index 0000000000..5c8cc0faa7 --- /dev/null +++ b/fieldservice_fleet/wizard/fsm_fleet_wizard.py @@ -0,0 +1,44 @@ +# Copyright (C) 2019 Open Source Integrators +# Copyright (C) 2019 Brian McMaster +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import _, models +from odoo.exceptions import UserError + + +class FSMFleetWizard(models.TransientModel): + """ + A wizard to convert a fleet.vehicle record to a fsm.vehicle + """ + + _name = "fsm.fleet.wizard" + _description = "FSM Fleet Vehicle Conversion" + + def action_convert(self): + vehicles = self.env["fleet.vehicle"].browse(self._context.get("active_ids", [])) + for vehicle in vehicles: + self.action_convert_vehicle(vehicle) + return {"type": "ir.actions.act_window_close"} + + def _prepare_fsm_vehicle(self, vehicle): + return { + "fleet_vehicle_id": vehicle.id, + "name": vehicle.name, + } + + def action_convert_vehicle(self, vehicle): + res = self.env["fsm.vehicle"].search_count( + [("fleet_vehicle_id", "=", vehicle.id)] + ) + if res == 0: + vals = self._prepare_fsm_vehicle(vehicle) + self.env["fsm.vehicle"].create(vals) + vehicle.write({"is_fsm_vehicle": True}) + vehicle.set_fsm_driver() + else: + raise UserError( + _( + "A Field Service Vehicle related to that" + " Fleet Vehicle already exists." + ) + ) diff --git a/fieldservice_fleet/wizard/fsm_fleet_wizard.xml b/fieldservice_fleet/wizard/fsm_fleet_wizard.xml new file mode 100644 index 0000000000..206024b902 --- /dev/null +++ b/fieldservice_fleet/wizard/fsm_fleet_wizard.xml @@ -0,0 +1,33 @@ + + + + + + Convert to a FSM Vehicle + fsm.fleet.wizard + +
+
+ Convert this vehicle record into a Field Service Vehicle. +
+ +
+
+
+
diff --git a/setup/fieldservice_fleet/odoo/addons/fieldservice_fleet b/setup/fieldservice_fleet/odoo/addons/fieldservice_fleet new file mode 120000 index 0000000000..18d39b0074 --- /dev/null +++ b/setup/fieldservice_fleet/odoo/addons/fieldservice_fleet @@ -0,0 +1 @@ +../../../../fieldservice_fleet \ No newline at end of file diff --git a/setup/fieldservice_fleet/setup.py b/setup/fieldservice_fleet/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/fieldservice_fleet/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)