Skip to content

Commit

Permalink
[ADD] - add shipment_advice_planner_toursolver
Browse files Browse the repository at this point in the history
This module extend the shipment advice planner engine to add a new planning
method based on geo-localization. It uses the GEOCONCEPT solution called
TourSolver to plan the shipment advices according to the location of the customers
by calculating the best route according to the available resources.

[IMP] - depends on base_time_window

[IMP] - add backend options as property field

[IMP] - improve UI and readme

[IMP] - add picking rank

[FIX] - add vcrpy-unittest to test-requirements.txt

[FIX] - group pickings to plan by picking type instead of the warehouse

[IMP] shipment_advice_planner_toursolver : fr translations

[IMP] add vcrpy-unittest

[FIX] - fix typo

[IMP] - allow toursolver task cancel

[IMP] - raise an exception if the toursolver backend is not configured

[IMP] - group system can delete toursolver tasks

[FIX] - don't copy toursolver task when duplicating a picking

[IMP] show toursolver rank in toursolver task

[IMP] add search for can_be_planned_in_shipment_advice

[IMP] shipment_advice_planner_toursolver: add unit tests

[IMP] allow more info in toursolver task name
  • Loading branch information
sbejaoui committed Feb 28, 2024
1 parent d6d5b3d commit 0de7ce5
Show file tree
Hide file tree
Showing 78 changed files with 5,620 additions and 0 deletions.
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# generated from manifests external_dependencies
requests
6 changes: 6 additions & 0 deletions setup/shipment_advice_planner_toursolver/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
6 changes: 6 additions & 0 deletions setup/shipment_advice_planner_toursolver_queue_job/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
119 changes: 119 additions & 0 deletions shipment_advice_planner_toursolver/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
==================================
Shipment Advice Planner Toursolver
==================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:77b508b2f4dff0ddc7494b46c43c42ca78f4e91fbab6d536e19205b508edf478
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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%2Fstock--logistics--transport-lightgray.png?logo=github
:target: https://github.com/OCA/stock-logistics-transport/tree/16.0/shipment_advice_planner_toursolver
:alt: OCA/stock-logistics-transport
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/stock-logistics-transport-16-0/stock-logistics-transport-16-0-shipment_advice_planner_toursolver
: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/stock-logistics-transport&target_branch=16.0
:alt: Try me on Runboat

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

This module extend the shipment advice planner engine to add a new planning
method based on geo-localization. It uses the GEOCONCEPT solution called
TourSolver to plan the shipment advices according to the location of the customers
by calculating the best route according to the available resources.

**Table of contents**

.. contents::
:local:

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

Before configuring this module, you must configure your account and your
resources on the TourSolver website. Then you should be able to get your api key
and paste it in the default backend. You can access to backends list under the
setting menu of the inventory module.

The second step is to create the resources. You can add the properties you want
TourSolver to use in its calculation of the best route.

For advanced planning, you can define your customer delivery windows. It will be
considered in TourSolver calculation.

For more details about the properties you can use, please consult
[TourSolver documentation](https://mygeoconcept.com/doc/6cc656Uv7gARvG6T/ts-cloud-doc/docs/en/toursolver-cloud-book/)

Usage
=====

In the shipment planner you will see a new option added to the planning methods.
If you select TourSolver, a TourSolver task per warehouse will be created for
the pickings you want to plan.

The task will pass through different states by a dedicated cron and at the end
of the process will create shipment advices according the returned result from
TourSolver.

Known issues / Roadmap
======================

At this stage, the TourSolver task is managed by a cron which will synchronize
its status with TourSolver and get the result when it is ready.
Another approach is available using queue jobs where the sync task will be
rescheduled until it gets the optimization result.

Ideally, a webhook can be developed to be notified by toursolver when the result
is ready. He will ensure that the result is obtained as soon as possible.

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/stock-logistics-transport/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/stock-logistics-transport/issues/new?body=module:%20shipment_advice_planner_toursolver%0Aversion:%2016.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
~~~~~~~

* ACSONE SA/NV

Contributors
~~~~~~~~~~~~

* Laurent Mignon <[email protected]>
* Souheil Bejaoui <[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.

This module is part of the `OCA/stock-logistics-transport <https://github.com/OCA/stock-logistics-transport/tree/16.0/shipment_advice_planner_toursolver>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions shipment_advice_planner_toursolver/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import models
from . import wizards
41 changes: 41 additions & 0 deletions shipment_advice_planner_toursolver/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright 2023 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Shipment Advice Planner Toursolver",
"summary": """Shipment advices planning by geo-optimization (TourSolver)""",
"version": "16.0.1.0.0",
"license": "AGPL-3",
"author": "ACSONE SA/NV,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/stock-logistics-transport",
"depends": ["shipment_advice_planner", "base_time_window"],
"data": [
# data
"data/toursolver_backend.xml",
"data/ir_ui_menu.xml",
"data/ir_sequence.xml",
"data/ir_cron.xml",
# security
"security/toursolver_backend.xml",
"security/toursolver_resource.xml",
"security/toursolver_task.xml",
"security/toursolver_delivery_window.xml",
"security/toursolver_backend_option_definition.xml",
# views
"views/toursolver_backend.xml",
"views/res_config_settings.xml",
"views/toursolver_resource.xml",
"views/stock_picking.xml",
"views/toursolver_delivery_window.xml",
"views/toursolver_task.xml",
"views/res_partner.xml",
# wizards
"wizards/shipment_advice_planner.xml",
],
"demo": [
"demo/toursolver_backend.xml",
"demo/toursolver_resource.xml",
"demo/res_compnay.xml",
],
"external_dependencies": {"python": ["requests"]},
}
16 changes: 16 additions & 0 deletions shipment_advice_planner_toursolver/data/ir_cron.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2023 ACSONE SA/NV
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo noupdate="1">
<record forcecreate="True" id="ir_cron_sync_toursolver_task" model="ir.cron">
<field name="name">Synchronize toursolver tasks</field>
<field name="user_id" ref="base.user_root" />
<field name="code">model._cron_sync_task()</field>
<field name="interval_number">5</field>
<field name="interval_type">minutes</field>
<field name="numbercall">-1</field>
<field name="active" eval="False" />
<field name="doall" eval="False" />
<field name="model_id" ref="model_toursolver_task" />
</record>
</odoo>
12 changes: 12 additions & 0 deletions shipment_advice_planner_toursolver/data/ir_sequence.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2023 ACSONE SA/NV
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo noupdate="1">
<record id="seq_toursolver_task" model="ir.sequence">
<field name="name">TourSolver Task</field>
<field name="code">toursolver.task</field>
<field name="prefix">TST/</field>
<field name="padding">8</field>
<field name="company_id" eval="False" />
</record>
</odoo>
12 changes: 12 additions & 0 deletions shipment_advice_planner_toursolver/data/ir_ui_menu.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2023 ACSONE SA/NV
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>

<record model="ir.ui.menu" id="toursolver_setting_menu">
<field name="name">TourSolver</field>
<field name="parent_id" ref="stock.menu_stock_config_settings" />
<field name="sequence" eval="16" />
</record>

</odoo>
10 changes: 10 additions & 0 deletions shipment_advice_planner_toursolver/data/toursolver_backend.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2023 ACSONE SA/NV
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo noupdate="1">

<record model="toursolver.backend" id="toursolver_backend_default">
<field name="name">TourSolver</field>
</record>

</odoo>
10 changes: 10 additions & 0 deletions shipment_advice_planner_toursolver/demo/res_compnay.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2023 ACSONE SA/NV
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo noupdate="1">

<record model="res.company" id="base.main_company">
<field name="toursolver_backend_id" ref="toursolver_backend_default" />
</record>

</odoo>
31 changes: 31 additions & 0 deletions shipment_advice_planner_toursolver/demo/toursolver_backend.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2023 ACSONE SA/NV
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo noupdate="1">
<record
model="toursolver.backend.option.definition"
id="toursolver_backend_definition_demo"
>
<field
name="backend_options_definition"
eval="[{'name': '1', 'type': 'char', 'string': 'vehicleCode', 'default': ''}, {'name': '2', 'type': 'boolean', 'string': 'useForbiddenTransitAreas', 'default': False}]"
/>
</record>

<record model="toursolver.backend" id="toursolver_backend_default">
<field
name="url"
>https://geoservices.geoconcept.com/ToursolverCloud/api/ts/toursolver/</field>
<field name="api_key">fake_api_key</field>
<field
name="resource_properties_definition"
eval="[{'name': '2', 'type': 'char', 'string': 'mobileLogin', 'default': False}, {'name': '3', 'type': 'boolean', 'string': 'openStart', 'default': False}, {'name': '4', 'type': 'boolean', 'string': 'loadBeforeDeparture', 'default': True}, {'name': '5', 'type': 'boolean', 'string': 'noReload', 'default': True}, {'name': '6', 'type': 'integer', 'string': 'globalCapacity', 'default': 9999}, {'name': '7', 'type': 'boolean', 'string': 'useAllCapacities', 'default': False}]"
/>
<field name="definition_id" ref="toursolver_backend_definition_demo" />
<field
name="backend_options"
eval="{'1': 'deliveryIntermediateVehicle', '2': False}"
/>
</record>

</odoo>
26 changes: 26 additions & 0 deletions shipment_advice_planner_toursolver/demo/toursolver_resource.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2023 ACSONE SA/NV
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo noupdate="1">

<record model="toursolver.resource" id="toursolver_resource_r1_demo">
<field name="name">R1</field>
<field name="resource_id">D1</field>
<field name="toursolver_backend_id" ref="toursolver_backend_default" />
<field
name="resource_properties"
eval="{'2': '[email protected]', '3': False, '4': True, '5': True, '6': 9999, '7': False}"
/>
</record>


<record model="toursolver.resource" id="toursolver_resource_r2_demo">
<field name="name">R2</field>
<field name="resource_id">D2</field>
<field name="toursolver_backend_id" ref="toursolver_backend_default" />
<field
name="resource_properties"
eval="{'2': '[email protected]', '3': False, '4': True, '5': True, '6': 9999, '7': False}"
/>
</record>
</odoo>
Loading

0 comments on commit 0de7ce5

Please sign in to comment.