Skip to content

Commit

Permalink
[IMP] fieldservice_vehicle_stock: Add fsm_vehicle_out for vehicle-to-…
Browse files Browse the repository at this point in the history
…location transfers

- Introduced `fsm_vehicle_out` field in `stock.picking.type` to support unloading inventory from FSM Vehicles.
- Updated transfer validation to handle both loading (fsm_vehicle_in) and unloading (fsm_vehicle_out) operations.
- Ensured proper location updates and validation when moving stock between FSM vehicles and locations.

This improvement extends the existing vehicle loading logic to also control stock transfers from vehicles to other locations.
  • Loading branch information
ppyczko committed Feb 6, 2025
1 parent 4a707a3 commit 3924967
Show file tree
Hide file tree
Showing 13 changed files with 438 additions and 156 deletions.
48 changes: 31 additions & 17 deletions fieldservice_vehicle_stock/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,7 @@ and process stock moves with field service vehicles.
In field service operations, the general flow of inventory is as follows:
Stock Location -> Vehicle Location -> Customer Location

Initially there is a demand for product in the Customer Location, but we
are not sure which field service vehicle needs to load that product until
a field service order and vehicle is planned.

This module will automatically update pickings linked to field service orders
so that inventory is moved to the proper vehicle storage locations.
This module will automatically update pickings linked to field service orders, ensuring that inventory is moved to the correct vehicle storage locations. These pickings have to be of an operation type that is used to load or unload a vehicle.

**Table of contents**

Expand Down Expand Up @@ -82,17 +77,36 @@ rule's Destination Location.
Usage
=====

To use this module you must first generate some stock moves that
that will be transferred using a stock operation type which supports
FSM vehicle loading.

In order to confirm the transfer, a FSM Vehicle must be set. The FSM
Vehicle can be set manually on the transfer in the Additional Info tab
or it will be automatically set if the transfer has a linked FSM Order
and a vehicle is assigned to that order.

When the FSM Vehicle is updated on a transfer, the destination locations
are updated to reflect the vehicle storage location.
1. **Create a Location for the Vehicle**
- Navigate to Inventory > Configuration > Locations and create a new location.
- Set a name.
- Set the `Parent Location` to `Vehicles`.
- Set the location type to `Internal Location`.
- Save the location.

2. **Create an FSM Vehicle**
- Navigate to Field Service > Master Data > Vehicles and create a new vehicle.
- Set a name.
- Assign a driver.
- Assign the location you created in step 1.
- Save the vehicle.
- Enter the driver's record and set the `Default Vehicle` field to the vehicle you just created.

3. **Generate Stock Moves**
- Navigate to Inventory > Operations > Transfers and create a new transfer.
- On the `Operation Type` field, select an operation type that supports FSM vehicle loading or unloading. Examples of this include `Vehicle Loading`, to load a vehicle from stock, and `Location Delivery`, to unload a vehicle to a customer location.
- Add the products you want to transfer and save the transfer.
- By default, the Source Location or Destination Location (depending on the selected operation type) will be set to the default `Vehicles` location.

4. **Validate the Transfer**
- In the `Additional Info` tab, set the FSM Vehicle on the transfer.
- If you link an FSM order to the transfer, and the FSM order has a vehicle assigned with a storage location that is a child of the `Vehicles` location, the vehicle and its corresponding location will be automatically set on the transfer.
- When validating the picking, the destination location of the picking and it's move lines will be updated to the vehicle's storage location. The assigned products will be moved from or to the vehicle location, depending on the selected operation type.
- If you try to confirm a transfer without setting the FSM Vehicle, an error will be raised.
- If you try to set a vehicle or link an FSM order with a vehicle whose storage location is not a child of the Vehicles location, an error will be raised.

Useful groups to manage this module:
- Technical / Manage Multiple Stock Locations

Known issues / Roadmap
======================
Expand Down
10 changes: 10 additions & 0 deletions fieldservice_vehicle_stock/data/fsm_stock_data.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@
<field name="sequence_code">OUT</field>
<field name="warehouse_id" eval="False" />
<field name="default_location_src_id" ref="stock_location_vehicle" />
<field
name="default_location_dest_id"
ref="stock.stock_location_customers"
/>
<field name="fsm_vehicle_out" eval="True" />
</record>

<!-- Route: Stock to Vehicle to Location -->
Expand Down Expand Up @@ -99,6 +104,10 @@
<field name="code">incoming</field>
<field name="sequence_code">IN</field>
<!-- <field name="warehouse_id" eval="False" /> -->
<field
name="default_location_src_id"
ref="stock.stock_location_customers"
/>
<field name="default_location_dest_id" ref="stock_location_vehicle" />
<field
name="return_picking_type_id"
Expand Down Expand Up @@ -134,6 +143,7 @@
<field name="default_location_src_id" ref="stock_location_vehicle" />
<field name="default_location_dest_id" ref="stock.stock_location_stock" />
<field name="return_picking_type_id" ref="picking_type_output_to_vehicle" />
<field name="fsm_vehicle_out" eval="True" />
</record>

<record id="stock_rule_vehicle_to_input" model="stock.rule">
Expand Down
136 changes: 136 additions & 0 deletions fieldservice_vehicle_stock/i18n/ca.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * fieldservice_vehicle_stock
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-02-04 13:50+0000\n"
"PO-Revision-Date: 2025-02-04 13:50+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_vehicle_stock
#: model:ir.model.fields,help:fieldservice_vehicle_stock.field_stock_picking_type__fsm_vehicle_in
msgid ""
"Check this box for operation types that will be used\n"
" to load inventory on FSM Vehicles."
msgstr ""
"Marqueu aquesta casella per als tipus d'operacions que s'utilitzaran\n"
" per carregar inventari als vehicles FSM."

#. module: fieldservice_vehicle_stock
#: model:ir.model.fields,help:fieldservice_vehicle_stock.field_stock_picking_type__fsm_vehicle_out
msgid ""
"Check this box for operation types that will be used\n"
" to unload inventory from FSM Vehicles."
msgstr ""
"Marqueu aquesta casella per als tipus d'operacions que s'utilitzaran\n"
" per descarregar inventari dels vehicles FSM."

#. module: fieldservice_vehicle_stock
#: model:ir.model,name:fieldservice_vehicle_stock.model_fsm_order
msgid "Field Service Order"
msgstr "Ordre de Servei de Camp"

#. module: fieldservice_vehicle_stock
#: model:ir.model,name:fieldservice_vehicle_stock.model_fsm_vehicle
msgid "Field Service Vehicle"
msgstr "Vehicle de Servei de Camp"

#. module: fieldservice_vehicle_stock
#: model:ir.model.fields,field_description:fieldservice_vehicle_stock.field_fsm_vehicle__inventory_location_id
msgid "Inventory Location"
msgstr "Ubicació d'Inventari"

#. module: fieldservice_vehicle_stock
#: model:stock.picking.type,name:fieldservice_vehicle_stock.picking_type_vehicle_to_location
msgid "Location Delivery"
msgstr "Lliurament a Ubicació"

#. module: fieldservice_vehicle_stock
#: model:stock.picking.type,name:fieldservice_vehicle_stock.picking_type_location_to_vehicle
msgid "Location Pickup"
msgstr "Recollida a Ubicació"

#. module: fieldservice_vehicle_stock
#: model:stock.location.route,name:fieldservice_vehicle_stock.route_location_return
msgid "Location Return"
msgstr "Devolució des de Ubicació"

#. module: fieldservice_vehicle_stock
#: model:ir.model,name:fieldservice_vehicle_stock.model_stock_picking_type
msgid "Picking Type"
msgstr "Tipus de Picking"

#. module: fieldservice_vehicle_stock
#: model:stock.location.route,name:fieldservice_vehicle_stock.route_stock_to_vehicle_to_location
msgid "Stock to Vehicle to Location"
msgstr "Estoc a Vehicle a Ubicació"

#. module: fieldservice_vehicle_stock
#: code:addons/fieldservice_vehicle_stock/models/stock_picking.py:0
#, python-format
msgid ""
"The inventory location of the FSM vehicle must be a descendant of the "
"Vehicles location."
msgstr ""
"La ubicació d'inventari del vehicle FSM ha de ser descendent de la ubicació "
"dels vehicles."

#. module: fieldservice_vehicle_stock
#: model:ir.model,name:fieldservice_vehicle_stock.model_stock_picking
msgid "Transfer"
msgstr "Transferència"

#. module: fieldservice_vehicle_stock
#: model:ir.model.fields,field_description:fieldservice_vehicle_stock.field_stock_picking_type__fsm_vehicle_in
msgid "Used to load a Field Service Vehicle"
msgstr "Utilitzat per carregar un Vehicle de Servei de Camp"

#. module: fieldservice_vehicle_stock
#: model:ir.model.fields,field_description:fieldservice_vehicle_stock.field_stock_picking_type__fsm_vehicle_out
msgid "Used to unload a Field Service Vehicle"
msgstr "Utilitzat per descarregar un Vehicle de Servei de Camp"

#. module: fieldservice_vehicle_stock
#: model:ir.model.fields,field_description:fieldservice_vehicle_stock.field_stock_picking__fsm_vehicle_id
msgid "Vehicle"
msgstr "Vehicle"

#. module: fieldservice_vehicle_stock
#: model:stock.picking.type,name:fieldservice_vehicle_stock.picking_type_output_to_vehicle
msgid "Vehicle Loading"
msgstr "Càrrega de Vehicle"

#. module: fieldservice_vehicle_stock
#: model:stock.picking.type,name:fieldservice_vehicle_stock.picking_type_vehicle_to_input
msgid "Vehicle Returns"
msgstr "Devolució des del vehicle"

#. module: fieldservice_vehicle_stock
#: model:stock.rule,name:fieldservice_vehicle_stock.procurement_rule_vehicle_to_location
msgid "Vehicle → Location"
msgstr "Vehicle → Ubicació"

#. module: fieldservice_vehicle_stock
#: model:stock.rule,name:fieldservice_vehicle_stock.stock_rule_vehicle_to_input
msgid "Vehicle → Warehouse"
msgstr "Vehicle → Magatzem"

#. module: fieldservice_vehicle_stock
#: model:stock.rule,name:fieldservice_vehicle_stock.procurement_rule_location_to_vehicle
#: model:stock.rule,name:fieldservice_vehicle_stock.procurement_rule_output_to_vehicle
msgid "Warehouse → Vehicle"
msgstr "Magatzem → Vehicle"

#. module: fieldservice_vehicle_stock
#: code:addons/fieldservice_vehicle_stock/models/stock_picking.py:0
#, python-format
msgid "You must provide the vehicle for this picking type."
msgstr "Heu de proporcionar el vehicle per a aquest tipus de picking."
105 changes: 49 additions & 56 deletions fieldservice_vehicle_stock/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,34 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2024-02-23 18:36+0000\n"
"Last-Translator: Ivorra78 <informatica@totmaterial.es>\n"
"Language-Team: none\n"
"Language: es\n"
"POT-Creation-Date: 2025-02-04 13:50+0000\n"
"PO-Revision-Date: 2025-02-04 13:50+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: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"
"Plural-Forms: \n"

#. module: fieldservice_vehicle_stock
#: model:ir.model.fields,field_description:fieldservice_vehicle_stock.field_fsm_vehicle__display_name
#: model:ir.model.fields,field_description:fieldservice_vehicle_stock.field_stock_picking__display_name
#: model:ir.model.fields,field_description:fieldservice_vehicle_stock.field_stock_putaway_rule__display_name
msgid "Display Name"
msgstr "Mostrar Nombre"
#: model:ir.model.fields,help:fieldservice_vehicle_stock.field_stock_picking_type__fsm_vehicle_in
msgid ""
"Check this box for operation types that will be used\n"
" to load inventory on FSM Vehicles."
msgstr ""
"Marque esta casilla para los tipos de operación que se utilizarán\n"
" para cargar inventario en los vehículos FSM."

#. module: fieldservice_vehicle_stock
#: model:ir.model.fields,help:fieldservice_vehicle_stock.field_stock_picking_type__fsm_vehicle_out
msgid ""
"Check this box for operation types that will be used\n"
" to unload inventory from FSM Vehicles."
msgstr ""
"Marque esta casilla para los tipos de operación que se utilizarán\n"
" para descargar inventario de los vehículos FSM."

#. module: fieldservice_vehicle_stock
#: model:ir.model,name:fieldservice_vehicle_stock.model_fsm_order
Expand All @@ -33,62 +43,60 @@ msgstr "Pedidos de Servicio de Campo"
msgid "Field Service Vehicle"
msgstr "Vehículo de Servicio de Campo"

#. module: fieldservice_vehicle_stock
#: model:ir.model.fields,field_description:fieldservice_vehicle_stock.field_fsm_order__id
#: model:ir.model.fields,field_description:fieldservice_vehicle_stock.field_fsm_vehicle__id
#: model:ir.model.fields,field_description:fieldservice_vehicle_stock.field_stock_picking__id
#: model:ir.model.fields,field_description:fieldservice_vehicle_stock.field_stock_putaway_rule__id
msgid "ID"
msgstr "ID"

#. module: fieldservice_vehicle_stock
#: model:ir.model.fields,field_description:fieldservice_vehicle_stock.field_fsm_vehicle__inventory_location_id
msgid "Inventory Location"
msgstr "Ubicación de Inventario"

#. module: fieldservice_vehicle_stock
#: model:ir.model.fields,field_description:fieldservice_vehicle_stock.field_fsm_order____last_update
#: model:ir.model.fields,field_description:fieldservice_vehicle_stock.field_fsm_vehicle____last_update
#: model:ir.model.fields,field_description:fieldservice_vehicle_stock.field_stock_picking____last_update
#: model:ir.model.fields,field_description:fieldservice_vehicle_stock.field_stock_putaway_rule____last_update
msgid "Last Modified on"
msgstr "Última Modificación el"

#. module: fieldservice_vehicle_stock
#: model:stock.picking.type,name:fieldservice_vehicle_stock.picking_type_vehicle_to_location
msgid "Location Delivery"
msgstr "Entrega de Ubicación"
msgstr "Entrega en ubicación"

#. module: fieldservice_vehicle_stock
#: model:stock.picking.type,name:fieldservice_vehicle_stock.picking_type_location_to_vehicle
msgid "Location Pickup"
msgstr "Ubicación de Recogida"
msgstr "Recogida en ubicación"

#. module: fieldservice_vehicle_stock
#: model:stock.location.route,name:fieldservice_vehicle_stock.route_location_return
msgid "Location Return"
msgstr "Ubicación de Retorno"
msgstr "Devolución desde ubicación"

#. module: fieldservice_vehicle_stock
#: model:ir.model.fields,field_description:fieldservice_vehicle_stock.field_fsm_order__display_name
msgid "Order"
msgstr "Pedido"

#. module: fieldservice_vehicle_stock
#: model:ir.model,name:fieldservice_vehicle_stock.model_stock_putaway_rule
msgid "Putaway Rule"
msgstr "Regla de Estrategia de Salida"
#: model:ir.model,name:fieldservice_vehicle_stock.model_stock_picking_type
msgid "Picking Type"
msgstr "Tipo de albarán"

#. module: fieldservice_vehicle_stock
#: model:stock.location.route,name:fieldservice_vehicle_stock.route_stock_to_vehicle_to_location
msgid "Stock to Vehicle to Location"
msgstr "Stock a Vehículo a Ubicación"

#. module: fieldservice_vehicle_stock
#: code:addons/fieldservice_vehicle_stock/models/stock_picking.py:0
#, python-format
msgid ""
"The inventory location of the FSM vehicle must be a descendant of the "
"Vehicles location."
msgstr "La ubicación de inventario del vehículo FSM debe ser descendiente de la ubicación de "
"los vehículos."

#. module: fieldservice_vehicle_stock
#: model:ir.model,name:fieldservice_vehicle_stock.model_stock_picking
msgid "Transfer"
msgstr "Transferir"

#. module: fieldservice_vehicle_stock
#: model:ir.model.fields,field_description:fieldservice_vehicle_stock.field_stock_picking_type__fsm_vehicle_in
msgid "Used to load a Field Service Vehicle"
msgstr "Utilizado para cargar un vehículo de Servicio de Campo"

#. module: fieldservice_vehicle_stock
#: model:ir.model.fields,field_description:fieldservice_vehicle_stock.field_stock_picking_type__fsm_vehicle_out
msgid "Used to unload a Field Service Vehicle"
msgstr "Utilizado para descargar un vehículo de Servicio de Campo"

#. module: fieldservice_vehicle_stock
#: model:ir.model.fields,field_description:fieldservice_vehicle_stock.field_stock_picking__fsm_vehicle_id
msgid "Vehicle"
Expand All @@ -97,12 +105,12 @@ msgstr "Vehículo"
#. module: fieldservice_vehicle_stock
#: model:stock.picking.type,name:fieldservice_vehicle_stock.picking_type_output_to_vehicle
msgid "Vehicle Loading"
msgstr "Carga del Vehículo"
msgstr "Carga del vehículo"

#. module: fieldservice_vehicle_stock
#: model:stock.picking.type,name:fieldservice_vehicle_stock.picking_type_vehicle_to_input
msgid "Vehicle Returns"
msgstr "Devoluciones de Vehículos"
msgstr "Devolución al almacén"

#. module: fieldservice_vehicle_stock
#: model:stock.rule,name:fieldservice_vehicle_stock.procurement_rule_vehicle_to_location
Expand All @@ -125,18 +133,3 @@ msgstr "Bodega → Vehículo"
#, python-format
msgid "You must provide the vehicle for this picking type."
msgstr "Debe proporcionar el vehículo para este tipo de picking."

#~ msgid "Put Away Strategy"
#~ msgstr "Estrategia de Traslado"

#~ msgid "Check Availability"
#~ msgstr "Consultar Disponibilidad"

#~ msgid "Deliver"
#~ msgstr "Despachar"

#~ msgid "Register lots, packs, location"
#~ msgstr "Registrar lotes, paquetes, ubicación"

#~ msgid "Stock Request"
#~ msgstr "Solicitud de Stock"
Loading

0 comments on commit 3924967

Please sign in to comment.