From e1dfcc69600466a1d66c6e7b72fdf19ac996f541 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20BEAU?= Date: Fri, 28 Jun 2019 15:36:26 +0200 Subject: [PATCH 1/7] [REF] refactor code split edition part in a separated module and add laposte support --- shopinvader_dropoff_site_laposte/__init__.py | 3 ++ .../__manifest__.py | 24 ++++++++++ .../readme/CONTRIBUTORS.rst | 1 + .../readme/CREDITS.rst | 3 ++ .../readme/DESCRIPTION.rst | 9 ++++ .../services/__init__.py | 3 ++ .../services/cart.py | 47 +++++++++++++++++++ .../tests/__init__.py | 3 ++ .../tests/test_dropoff_site.py | 21 +++++++++ 9 files changed, 114 insertions(+) create mode 100644 shopinvader_dropoff_site_laposte/__init__.py create mode 100644 shopinvader_dropoff_site_laposte/__manifest__.py create mode 100644 shopinvader_dropoff_site_laposte/readme/CONTRIBUTORS.rst create mode 100644 shopinvader_dropoff_site_laposte/readme/CREDITS.rst create mode 100644 shopinvader_dropoff_site_laposte/readme/DESCRIPTION.rst create mode 100644 shopinvader_dropoff_site_laposte/services/__init__.py create mode 100644 shopinvader_dropoff_site_laposte/services/cart.py create mode 100644 shopinvader_dropoff_site_laposte/tests/__init__.py create mode 100644 shopinvader_dropoff_site_laposte/tests/test_dropoff_site.py diff --git a/shopinvader_dropoff_site_laposte/__init__.py b/shopinvader_dropoff_site_laposte/__init__.py new file mode 100644 index 0000000..54b9afb --- /dev/null +++ b/shopinvader_dropoff_site_laposte/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import services diff --git a/shopinvader_dropoff_site_laposte/__manifest__.py b/shopinvader_dropoff_site_laposte/__manifest__.py new file mode 100644 index 0000000..cc2d41f --- /dev/null +++ b/shopinvader_dropoff_site_laposte/__manifest__.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +# Copyright 2019 Akretion (http://www.akretion.com) +# Sébastien BEAU +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +{ + "name": "Shopinvader Dropoff site Public Edition", + "summary": "Shopinvader Dropoff site Public Edition", + "version": "10.0.0.0.0", + "category": "e-commerce", + "website": "https://akretion.com", + "author": "Akretion", + "license": "AGPL-3", + "application": False, + "installable": True, + "external_dependencies": {"python": [], "bin": []}, + "depends": [ + "shopinvader_dropoff_site_edition", + "delivery_roulier_laposte", + ], + "data": [], + "demo": [], + "qweb": [], +} diff --git a/shopinvader_dropoff_site_laposte/readme/CONTRIBUTORS.rst b/shopinvader_dropoff_site_laposte/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000..4be8cbf --- /dev/null +++ b/shopinvader_dropoff_site_laposte/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Sebastien BEAU diff --git a/shopinvader_dropoff_site_laposte/readme/CREDITS.rst b/shopinvader_dropoff_site_laposte/readme/CREDITS.rst new file mode 100644 index 0000000..fdc8ca1 --- /dev/null +++ b/shopinvader_dropoff_site_laposte/readme/CREDITS.rst @@ -0,0 +1,3 @@ +The development of this module has been financially supported by: + +* Akretion diff --git a/shopinvader_dropoff_site_laposte/readme/DESCRIPTION.rst b/shopinvader_dropoff_site_laposte/readme/DESCRIPTION.rst new file mode 100644 index 0000000..8e0eb54 --- /dev/null +++ b/shopinvader_dropoff_site_laposte/readme/DESCRIPTION.rst @@ -0,0 +1,9 @@ +This is shopinvader the odoo module for the new generation of e-commerce. + +This module add the support of la poste dropoff site with the solution "Front PagePointRetrait". + +See documentation here: +.. _Front Page Point Relais: https://www.colissimo.entreprise.laposte.fr/fr/system/files/imagescontent/docs/FPPR-FR.pdf + + +.. _Shopinvader: https://shopinvader.com diff --git a/shopinvader_dropoff_site_laposte/services/__init__.py b/shopinvader_dropoff_site_laposte/services/__init__.py new file mode 100644 index 0000000..34405c3 --- /dev/null +++ b/shopinvader_dropoff_site_laposte/services/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import cart diff --git a/shopinvader_dropoff_site_laposte/services/cart.py b/shopinvader_dropoff_site_laposte/services/cart.py new file mode 100644 index 0000000..4783714 --- /dev/null +++ b/shopinvader_dropoff_site_laposte/services/cart.py @@ -0,0 +1,47 @@ +# -*- coding: utf-8 -*- +# Copyright 2019 Akretion (http://www.akretion.com). +# @author Sébastien BEAU +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +import logging + +import requests +from odoo import _ +from odoo.addons.component.core import Component +from odoo.addons.delivery_roulier_laposte.models.keychain import ( + LAPOSTE_KEYCHAIN_NAMESPACE, +) +from odoo.exceptions import Warning as UserError + +_logger = logging.getLogger(__name__) + +LAPOSTE_API_ENDPOINT = "https://ws.colissimo.fr/widget-point-retrait/rest/" + + +class CartService(Component): + _inherit = "shopinvader.cart.service" + + def get_laposte_dropoff_site_token(self): + account = self._get_laposte_account() + response = requests.post( + LAPOSTE_API_ENDPOINT + "authenticate.rest", + json={"login": account.login, "password": account._get_password()}, + ) + if response.status_code == 200: + return response.json() + else: + _logger.error( + "La poste error %s %s", response.status_code, response.text + ) + raise UserError(_("Authentification Error with laposte")) + + def _get_laposte_account(self): + return ( + self.env["keychain.account"] + .suspend_security() + .retrieve([["namespace", "=", LAPOSTE_KEYCHAIN_NAMESPACE]]) + ) + + # Validator + def _validator_get_laposte_dropoff_site_token(self): + return {} diff --git a/shopinvader_dropoff_site_laposte/tests/__init__.py b/shopinvader_dropoff_site_laposte/tests/__init__.py new file mode 100644 index 0000000..d59a501 --- /dev/null +++ b/shopinvader_dropoff_site_laposte/tests/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import test_dropoff_site diff --git a/shopinvader_dropoff_site_laposte/tests/test_dropoff_site.py b/shopinvader_dropoff_site_laposte/tests/test_dropoff_site.py new file mode 100644 index 0000000..974d2e2 --- /dev/null +++ b/shopinvader_dropoff_site_laposte/tests/test_dropoff_site.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Copyright 2019 Akretion (http://www.akretion.com). +# @author Sébastien BEAU +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +import requests_mock +from odoo.addons.shopinvader.tests.common import CommonCase + + +class TokenCase(CommonCase): + def test_get_token(self): + with self.work_on_services() as work: + with requests_mock.mock() as m: + m.post( + "https://ws.colissimo.fr/widget-point-retrait" + "/rest/authenticate.rest", + json={"token": "laposte_token"}, + ) + service = work.component(usage="cart") + res = service.dispatch("get_laposte_dropoff_site_token") + self.assertEqual(res, {"token": "laposte_token"}) From ca50322f4fdb318ecfd820a6ada6456195d78104 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20BEAU?= Date: Mon, 1 Jul 2019 15:12:20 +0200 Subject: [PATCH 2/7] [FIX] add missing controller to have the token with a get method --- shopinvader_dropoff_site_laposte/__init__.py | 1 + .../controllers/__init__.py | 1 + .../controllers/main.py | 19 +++++++++++++++++++ 3 files changed, 21 insertions(+) create mode 100644 shopinvader_dropoff_site_laposte/controllers/__init__.py create mode 100644 shopinvader_dropoff_site_laposte/controllers/main.py diff --git a/shopinvader_dropoff_site_laposte/__init__.py b/shopinvader_dropoff_site_laposte/__init__.py index 54b9afb..8ea8eab 100644 --- a/shopinvader_dropoff_site_laposte/__init__.py +++ b/shopinvader_dropoff_site_laposte/__init__.py @@ -1,3 +1,4 @@ # -*- coding: utf-8 -*- from . import services +from . import controllers diff --git a/shopinvader_dropoff_site_laposte/controllers/__init__.py b/shopinvader_dropoff_site_laposte/controllers/__init__.py new file mode 100644 index 0000000..12a7e52 --- /dev/null +++ b/shopinvader_dropoff_site_laposte/controllers/__init__.py @@ -0,0 +1 @@ +from . import main diff --git a/shopinvader_dropoff_site_laposte/controllers/main.py b/shopinvader_dropoff_site_laposte/controllers/main.py new file mode 100644 index 0000000..42119f1 --- /dev/null +++ b/shopinvader_dropoff_site_laposte/controllers/main.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +# Copyright 2018 ACSONE Sa/ (http://www.acsone.eu) +# Cédric Pigeon +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +import logging + +from odoo.addons.shopinvader.controllers import main +from odoo.http import route + +_logger = logging.getLogger(__name__) + + +class InvaderController(main.InvaderController): + @route(["/shopinvader/cart/get_laposte_dropoff_site_token"], + methods=["GET"]) + def get_delivery_methods(self, **params): + return self._process_method( + "cart", "get_laposte_dropoff_site_token", params) From b09c1ca1dcda96615f055c3738e6d1213617f75d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20BEAU?= Date: Tue, 22 Oct 2019 14:48:12 +0200 Subject: [PATCH 3/7] [REF] refactor code due to change in base module --- .../__init__.py | 0 .../__manifest__.py | 2 +- .../controllers/__init__.py | 0 .../controllers/main.py | 0 .../readme/CONTRIBUTORS.rst | 0 .../readme/CREDITS.rst | 0 .../readme/DESCRIPTION.rst | 0 .../services/__init__.py | 3 +++ .../services/delivery_pickup.py | 21 ++++++++++--------- .../tests/__init__.py | 3 +++ .../tests/test_pickup_token.py | 6 ++++-- .../services/__init__.py | 3 --- .../tests/__init__.py | 3 --- 13 files changed, 22 insertions(+), 19 deletions(-) rename {shopinvader_dropoff_site_laposte => shopinvader_delivery_pickup_colissimo_widget}/__init__.py (100%) rename {shopinvader_dropoff_site_laposte => shopinvader_delivery_pickup_colissimo_widget}/__manifest__.py (92%) rename {shopinvader_dropoff_site_laposte => shopinvader_delivery_pickup_colissimo_widget}/controllers/__init__.py (100%) rename {shopinvader_dropoff_site_laposte => shopinvader_delivery_pickup_colissimo_widget}/controllers/main.py (100%) rename {shopinvader_dropoff_site_laposte => shopinvader_delivery_pickup_colissimo_widget}/readme/CONTRIBUTORS.rst (100%) rename {shopinvader_dropoff_site_laposte => shopinvader_delivery_pickup_colissimo_widget}/readme/CREDITS.rst (100%) rename {shopinvader_dropoff_site_laposte => shopinvader_delivery_pickup_colissimo_widget}/readme/DESCRIPTION.rst (100%) create mode 100644 shopinvader_delivery_pickup_colissimo_widget/services/__init__.py rename shopinvader_dropoff_site_laposte/services/cart.py => shopinvader_delivery_pickup_colissimo_widget/services/delivery_pickup.py (66%) create mode 100644 shopinvader_delivery_pickup_colissimo_widget/tests/__init__.py rename shopinvader_dropoff_site_laposte/tests/test_dropoff_site.py => shopinvader_delivery_pickup_colissimo_widget/tests/test_pickup_token.py (72%) delete mode 100644 shopinvader_dropoff_site_laposte/services/__init__.py delete mode 100644 shopinvader_dropoff_site_laposte/tests/__init__.py diff --git a/shopinvader_dropoff_site_laposte/__init__.py b/shopinvader_delivery_pickup_colissimo_widget/__init__.py similarity index 100% rename from shopinvader_dropoff_site_laposte/__init__.py rename to shopinvader_delivery_pickup_colissimo_widget/__init__.py diff --git a/shopinvader_dropoff_site_laposte/__manifest__.py b/shopinvader_delivery_pickup_colissimo_widget/__manifest__.py similarity index 92% rename from shopinvader_dropoff_site_laposte/__manifest__.py rename to shopinvader_delivery_pickup_colissimo_widget/__manifest__.py index cc2d41f..3cac2bb 100644 --- a/shopinvader_dropoff_site_laposte/__manifest__.py +++ b/shopinvader_delivery_pickup_colissimo_widget/__manifest__.py @@ -15,7 +15,7 @@ "installable": True, "external_dependencies": {"python": [], "bin": []}, "depends": [ - "shopinvader_dropoff_site_edition", + "shopinvader_delivery_pickup_public_edition", "delivery_roulier_laposte", ], "data": [], diff --git a/shopinvader_dropoff_site_laposte/controllers/__init__.py b/shopinvader_delivery_pickup_colissimo_widget/controllers/__init__.py similarity index 100% rename from shopinvader_dropoff_site_laposte/controllers/__init__.py rename to shopinvader_delivery_pickup_colissimo_widget/controllers/__init__.py diff --git a/shopinvader_dropoff_site_laposte/controllers/main.py b/shopinvader_delivery_pickup_colissimo_widget/controllers/main.py similarity index 100% rename from shopinvader_dropoff_site_laposte/controllers/main.py rename to shopinvader_delivery_pickup_colissimo_widget/controllers/main.py diff --git a/shopinvader_dropoff_site_laposte/readme/CONTRIBUTORS.rst b/shopinvader_delivery_pickup_colissimo_widget/readme/CONTRIBUTORS.rst similarity index 100% rename from shopinvader_dropoff_site_laposte/readme/CONTRIBUTORS.rst rename to shopinvader_delivery_pickup_colissimo_widget/readme/CONTRIBUTORS.rst diff --git a/shopinvader_dropoff_site_laposte/readme/CREDITS.rst b/shopinvader_delivery_pickup_colissimo_widget/readme/CREDITS.rst similarity index 100% rename from shopinvader_dropoff_site_laposte/readme/CREDITS.rst rename to shopinvader_delivery_pickup_colissimo_widget/readme/CREDITS.rst diff --git a/shopinvader_dropoff_site_laposte/readme/DESCRIPTION.rst b/shopinvader_delivery_pickup_colissimo_widget/readme/DESCRIPTION.rst similarity index 100% rename from shopinvader_dropoff_site_laposte/readme/DESCRIPTION.rst rename to shopinvader_delivery_pickup_colissimo_widget/readme/DESCRIPTION.rst diff --git a/shopinvader_delivery_pickup_colissimo_widget/services/__init__.py b/shopinvader_delivery_pickup_colissimo_widget/services/__init__.py new file mode 100644 index 0000000..9ce91db --- /dev/null +++ b/shopinvader_delivery_pickup_colissimo_widget/services/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import delivery_pickup diff --git a/shopinvader_dropoff_site_laposte/services/cart.py b/shopinvader_delivery_pickup_colissimo_widget/services/delivery_pickup.py similarity index 66% rename from shopinvader_dropoff_site_laposte/services/cart.py rename to shopinvader_delivery_pickup_colissimo_widget/services/delivery_pickup.py index 4783714..e863e38 100644 --- a/shopinvader_dropoff_site_laposte/services/cart.py +++ b/shopinvader_delivery_pickup_colissimo_widget/services/delivery_pickup.py @@ -18,14 +18,14 @@ LAPOSTE_API_ENDPOINT = "https://ws.colissimo.fr/widget-point-retrait/rest/" -class CartService(Component): - _inherit = "shopinvader.cart.service" +class DeliveryPickupService(Component): + _inherit = "shopinvader.delivery.pickup.service" - def get_laposte_dropoff_site_token(self): - account = self._get_laposte_account() + def get_colissimo_pickup_token(self): + login, password = self._get_laposte_account() response = requests.post( LAPOSTE_API_ENDPOINT + "authenticate.rest", - json={"login": account.login, "password": account._get_password()}, + json={"login": login, "password": password}, ) if response.status_code == 200: return response.json() @@ -36,12 +36,13 @@ def get_laposte_dropoff_site_token(self): raise UserError(_("Authentification Error with laposte")) def _get_laposte_account(self): - return ( - self.env["keychain.account"] - .suspend_security() + # Note for now we use keychain because the delivery module use it + # we will remove it later + account = self.env["keychain.account"]\ + .suspend_security()\ .retrieve([["namespace", "=", LAPOSTE_KEYCHAIN_NAMESPACE]]) - ) + return account.login, account._get_password() # Validator - def _validator_get_laposte_dropoff_site_token(self): + def _validator_get_colissimo_pickup_token(self): return {} diff --git a/shopinvader_delivery_pickup_colissimo_widget/tests/__init__.py b/shopinvader_delivery_pickup_colissimo_widget/tests/__init__.py new file mode 100644 index 0000000..5e88e05 --- /dev/null +++ b/shopinvader_delivery_pickup_colissimo_widget/tests/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import test_pickup_token diff --git a/shopinvader_dropoff_site_laposte/tests/test_dropoff_site.py b/shopinvader_delivery_pickup_colissimo_widget/tests/test_pickup_token.py similarity index 72% rename from shopinvader_dropoff_site_laposte/tests/test_dropoff_site.py rename to shopinvader_delivery_pickup_colissimo_widget/tests/test_pickup_token.py index 974d2e2..276e0c7 100644 --- a/shopinvader_dropoff_site_laposte/tests/test_dropoff_site.py +++ b/shopinvader_delivery_pickup_colissimo_widget/tests/test_pickup_token.py @@ -9,6 +9,8 @@ class TokenCase(CommonCase): def test_get_token(self): + account = self.env.ref('delivery_roulier_laposte.keychain_la_poste') + account.clear_password = "laposte_token" with self.work_on_services() as work: with requests_mock.mock() as m: m.post( @@ -16,6 +18,6 @@ def test_get_token(self): "/rest/authenticate.rest", json={"token": "laposte_token"}, ) - service = work.component(usage="cart") - res = service.dispatch("get_laposte_dropoff_site_token") + service = work.component(usage="delivery_pickup") + res = service.dispatch("get_colissimo_pickup_token") self.assertEqual(res, {"token": "laposte_token"}) diff --git a/shopinvader_dropoff_site_laposte/services/__init__.py b/shopinvader_dropoff_site_laposte/services/__init__.py deleted file mode 100644 index 34405c3..0000000 --- a/shopinvader_dropoff_site_laposte/services/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -# -*- coding: utf-8 -*- - -from . import cart diff --git a/shopinvader_dropoff_site_laposte/tests/__init__.py b/shopinvader_dropoff_site_laposte/tests/__init__.py deleted file mode 100644 index d59a501..0000000 --- a/shopinvader_dropoff_site_laposte/tests/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -# -*- coding: utf-8 -*- - -from . import test_dropoff_site From 97389846ebf6704161b6e8c8ad5ccdae9440355e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20BEAU?= Date: Tue, 22 Oct 2019 17:07:54 +0200 Subject: [PATCH 4/7] [FIx] fix test and fix consistency of service name --- .../tests/test_pickup_token.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shopinvader_delivery_pickup_colissimo_widget/tests/test_pickup_token.py b/shopinvader_delivery_pickup_colissimo_widget/tests/test_pickup_token.py index 276e0c7..aeaf20e 100644 --- a/shopinvader_delivery_pickup_colissimo_widget/tests/test_pickup_token.py +++ b/shopinvader_delivery_pickup_colissimo_widget/tests/test_pickup_token.py @@ -18,6 +18,6 @@ def test_get_token(self): "/rest/authenticate.rest", json={"token": "laposte_token"}, ) - service = work.component(usage="delivery_pickup") + service = work.component(usage="delivery_pickups") res = service.dispatch("get_colissimo_pickup_token") self.assertEqual(res, {"token": "laposte_token"}) From e961c84195fa2e3dc5488af5a40fd8805c58f3f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20BEAU?= Date: Tue, 22 Oct 2019 18:32:03 +0200 Subject: [PATCH 5/7] [FIX] fix wrong controller name --- .../controllers/main.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/shopinvader_delivery_pickup_colissimo_widget/controllers/main.py b/shopinvader_delivery_pickup_colissimo_widget/controllers/main.py index 42119f1..82a914d 100644 --- a/shopinvader_delivery_pickup_colissimo_widget/controllers/main.py +++ b/shopinvader_delivery_pickup_colissimo_widget/controllers/main.py @@ -12,8 +12,8 @@ class InvaderController(main.InvaderController): - @route(["/shopinvader/cart/get_laposte_dropoff_site_token"], + @route(["/shopinvader/delivery_pickups/get_colissimo_pickup_token"], methods=["GET"]) - def get_delivery_methods(self, **params): + def get_colissimo_pickup_token(self, **params): return self._process_method( - "cart", "get_laposte_dropoff_site_token", params) + "delivery_pickups", "get_colissimo_pickup_token", params) From e6126bf8c4d9ecf357eebee228aac9e77f099f5f Mon Sep 17 00:00:00 2001 From: "chafique.delli" Date: Thu, 6 Jun 2024 14:23:20 +0200 Subject: [PATCH 6/7] [16.0][MIG] shopinvader_delivery_pickup_colissimo_widget --- setup/.setuptools-odoo-make-default-ignore | 2 + setup/README | 2 + ...vader_api_delivery_pickup_colissimo_widget | 1 + .../setup.py | 6 + .../README.rst | 77 ++++ .../__init__.py | 1 + .../__manifest__.py | 18 +- .../data/ir_config_parameter_data.xml | 15 + .../readme/CONTRIBUTORS.rst | 1 + .../readme/CREDITS.rst | 0 .../readme/DESCRIPTION.rst | 0 .../routers}/__init__.py | 2 - .../routers/delivery_pickup.py | 61 +++ .../schemas/__init__.py | 1 + .../delivery_colissimo_pickup_token.py | 8 + .../static/description/index.html | 428 ++++++++++++++++++ .../__init__.py | 4 - .../controllers/__init__.py | 1 - .../controllers/main.py | 19 - .../services/delivery_pickup.py | 48 -- .../tests/__init__.py | 3 - .../tests/test_pickup_token.py | 23 - 22 files changed, 612 insertions(+), 109 deletions(-) create mode 100644 setup/.setuptools-odoo-make-default-ignore create mode 100644 setup/README create mode 120000 setup/shopinvader_api_delivery_pickup_colissimo_widget/odoo/addons/shopinvader_api_delivery_pickup_colissimo_widget create mode 100644 setup/shopinvader_api_delivery_pickup_colissimo_widget/setup.py create mode 100644 shopinvader_api_delivery_pickup_colissimo_widget/README.rst create mode 100644 shopinvader_api_delivery_pickup_colissimo_widget/__init__.py rename {shopinvader_delivery_pickup_colissimo_widget => shopinvader_api_delivery_pickup_colissimo_widget}/__manifest__.py (53%) create mode 100644 shopinvader_api_delivery_pickup_colissimo_widget/data/ir_config_parameter_data.xml rename {shopinvader_delivery_pickup_colissimo_widget => shopinvader_api_delivery_pickup_colissimo_widget}/readme/CONTRIBUTORS.rst (50%) rename {shopinvader_delivery_pickup_colissimo_widget => shopinvader_api_delivery_pickup_colissimo_widget}/readme/CREDITS.rst (100%) rename {shopinvader_delivery_pickup_colissimo_widget => shopinvader_api_delivery_pickup_colissimo_widget}/readme/DESCRIPTION.rst (100%) rename {shopinvader_delivery_pickup_colissimo_widget/services => shopinvader_api_delivery_pickup_colissimo_widget/routers}/__init__.py (54%) create mode 100644 shopinvader_api_delivery_pickup_colissimo_widget/routers/delivery_pickup.py create mode 100644 shopinvader_api_delivery_pickup_colissimo_widget/schemas/__init__.py create mode 100644 shopinvader_api_delivery_pickup_colissimo_widget/schemas/delivery_colissimo_pickup_token.py create mode 100644 shopinvader_api_delivery_pickup_colissimo_widget/static/description/index.html delete mode 100644 shopinvader_delivery_pickup_colissimo_widget/__init__.py delete mode 100644 shopinvader_delivery_pickup_colissimo_widget/controllers/__init__.py delete mode 100644 shopinvader_delivery_pickup_colissimo_widget/controllers/main.py delete mode 100644 shopinvader_delivery_pickup_colissimo_widget/services/delivery_pickup.py delete mode 100644 shopinvader_delivery_pickup_colissimo_widget/tests/__init__.py delete mode 100644 shopinvader_delivery_pickup_colissimo_widget/tests/test_pickup_token.py diff --git a/setup/.setuptools-odoo-make-default-ignore b/setup/.setuptools-odoo-make-default-ignore new file mode 100644 index 0000000..207e615 --- /dev/null +++ b/setup/.setuptools-odoo-make-default-ignore @@ -0,0 +1,2 @@ +# addons listed in this file are ignored by +# setuptools-odoo-make-default (one addon per line) diff --git a/setup/README b/setup/README new file mode 100644 index 0000000..a63d633 --- /dev/null +++ b/setup/README @@ -0,0 +1,2 @@ +To learn more about this directory, please visit +https://pypi.python.org/pypi/setuptools-odoo diff --git a/setup/shopinvader_api_delivery_pickup_colissimo_widget/odoo/addons/shopinvader_api_delivery_pickup_colissimo_widget b/setup/shopinvader_api_delivery_pickup_colissimo_widget/odoo/addons/shopinvader_api_delivery_pickup_colissimo_widget new file mode 120000 index 0000000..278abc2 --- /dev/null +++ b/setup/shopinvader_api_delivery_pickup_colissimo_widget/odoo/addons/shopinvader_api_delivery_pickup_colissimo_widget @@ -0,0 +1 @@ +../../../../shopinvader_api_delivery_pickup_colissimo_widget \ No newline at end of file diff --git a/setup/shopinvader_api_delivery_pickup_colissimo_widget/setup.py b/setup/shopinvader_api_delivery_pickup_colissimo_widget/setup.py new file mode 100644 index 0000000..28c57bb --- /dev/null +++ b/setup/shopinvader_api_delivery_pickup_colissimo_widget/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/shopinvader_api_delivery_pickup_colissimo_widget/README.rst b/shopinvader_api_delivery_pickup_colissimo_widget/README.rst new file mode 100644 index 0000000..196e2d8 --- /dev/null +++ b/shopinvader_api_delivery_pickup_colissimo_widget/README.rst @@ -0,0 +1,77 @@ +============================ +Shopinvader Pickup Colissimo +============================ + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:33018a07e970ac37422c211d6868173b5d18970b11eef184ca9f565876e50d42 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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-shopinvader%2Fodoo--shopinvader--carrier-lightgray.png?logo=github + :target: https://github.com/shopinvader/odoo-shopinvader-carrier/tree/16.0/shopinvader_api_delivery_pickup_colissimo_widget + :alt: shopinvader/odoo-shopinvader-carrier + +|badge1| |badge2| |badge3| + +This is shopinvader the odoo module for the new generation of e-commerce. + +This module add the support of la poste dropoff site with the solution "Front PagePointRetrait". + +See documentation here: +.. _Front Page Point Relais: https://www.colissimo.entreprise.laposte.fr/fr/system/files/imagescontent/docs/FPPR-FR.pdf + + +.. _Shopinvader: https://shopinvader.com + +**Table of contents** + +.. contents:: + :local: + +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 to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Akretion +* Shopinvader + +Contributors +~~~~~~~~~~~~ + +* Sebastien BEAU +* Chafique DELLI + +Other credits +~~~~~~~~~~~~~ + +The development of this module has been financially supported by: + +* Akretion + +Maintainers +~~~~~~~~~~~ + +This module is part of the `shopinvader/odoo-shopinvader-carrier `_ project on GitHub. + +You are welcome to contribute. diff --git a/shopinvader_api_delivery_pickup_colissimo_widget/__init__.py b/shopinvader_api_delivery_pickup_colissimo_widget/__init__.py new file mode 100644 index 0000000..62a5d54 --- /dev/null +++ b/shopinvader_api_delivery_pickup_colissimo_widget/__init__.py @@ -0,0 +1 @@ +from . import routers diff --git a/shopinvader_delivery_pickup_colissimo_widget/__manifest__.py b/shopinvader_api_delivery_pickup_colissimo_widget/__manifest__.py similarity index 53% rename from shopinvader_delivery_pickup_colissimo_widget/__manifest__.py rename to shopinvader_api_delivery_pickup_colissimo_widget/__manifest__.py index 3cac2bb..44711b5 100644 --- a/shopinvader_delivery_pickup_colissimo_widget/__manifest__.py +++ b/shopinvader_api_delivery_pickup_colissimo_widget/__manifest__.py @@ -1,24 +1,24 @@ -# -*- coding: utf-8 -*- # Copyright 2019 Akretion (http://www.akretion.com) # Sébastien BEAU # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { - "name": "Shopinvader Dropoff site Public Edition", - "summary": "Shopinvader Dropoff site Public Edition", - "version": "10.0.0.0.0", + "name": "Shopinvader Pickup Colissimo", + "summary": "Shopinvader Pickup Colissimo", + "version": "16.0.1.0.0", "category": "e-commerce", - "website": "https://akretion.com", - "author": "Akretion", + "website": "https://github.com/shopinvader/odoo-shopinvader-carrier", + "author": "Akretion, Shopinvader", "license": "AGPL-3", "application": False, "installable": True, "external_dependencies": {"python": [], "bin": []}, "depends": [ - "shopinvader_delivery_pickup_public_edition", - "delivery_roulier_laposte", + "shopinvader_api_delivery_pickup", + ], + "data": [ + "data/ir_config_parameter_data.xml", ], - "data": [], "demo": [], "qweb": [], } diff --git a/shopinvader_api_delivery_pickup_colissimo_widget/data/ir_config_parameter_data.xml b/shopinvader_api_delivery_pickup_colissimo_widget/data/ir_config_parameter_data.xml new file mode 100644 index 0000000..203f670 --- /dev/null +++ b/shopinvader_api_delivery_pickup_colissimo_widget/data/ir_config_parameter_data.xml @@ -0,0 +1,15 @@ + + + + + + laposte.user + + + + + laposte.password + + + + diff --git a/shopinvader_delivery_pickup_colissimo_widget/readme/CONTRIBUTORS.rst b/shopinvader_api_delivery_pickup_colissimo_widget/readme/CONTRIBUTORS.rst similarity index 50% rename from shopinvader_delivery_pickup_colissimo_widget/readme/CONTRIBUTORS.rst rename to shopinvader_api_delivery_pickup_colissimo_widget/readme/CONTRIBUTORS.rst index 4be8cbf..36cc592 100644 --- a/shopinvader_delivery_pickup_colissimo_widget/readme/CONTRIBUTORS.rst +++ b/shopinvader_api_delivery_pickup_colissimo_widget/readme/CONTRIBUTORS.rst @@ -1 +1,2 @@ * Sebastien BEAU +* Chafique DELLI diff --git a/shopinvader_delivery_pickup_colissimo_widget/readme/CREDITS.rst b/shopinvader_api_delivery_pickup_colissimo_widget/readme/CREDITS.rst similarity index 100% rename from shopinvader_delivery_pickup_colissimo_widget/readme/CREDITS.rst rename to shopinvader_api_delivery_pickup_colissimo_widget/readme/CREDITS.rst diff --git a/shopinvader_delivery_pickup_colissimo_widget/readme/DESCRIPTION.rst b/shopinvader_api_delivery_pickup_colissimo_widget/readme/DESCRIPTION.rst similarity index 100% rename from shopinvader_delivery_pickup_colissimo_widget/readme/DESCRIPTION.rst rename to shopinvader_api_delivery_pickup_colissimo_widget/readme/DESCRIPTION.rst diff --git a/shopinvader_delivery_pickup_colissimo_widget/services/__init__.py b/shopinvader_api_delivery_pickup_colissimo_widget/routers/__init__.py similarity index 54% rename from shopinvader_delivery_pickup_colissimo_widget/services/__init__.py rename to shopinvader_api_delivery_pickup_colissimo_widget/routers/__init__.py index 9ce91db..34936a0 100644 --- a/shopinvader_delivery_pickup_colissimo_widget/services/__init__.py +++ b/shopinvader_api_delivery_pickup_colissimo_widget/routers/__init__.py @@ -1,3 +1 @@ -# -*- coding: utf-8 -*- - from . import delivery_pickup diff --git a/shopinvader_api_delivery_pickup_colissimo_widget/routers/delivery_pickup.py b/shopinvader_api_delivery_pickup_colissimo_widget/routers/delivery_pickup.py new file mode 100644 index 0000000..7ad1c3a --- /dev/null +++ b/shopinvader_api_delivery_pickup_colissimo_widget/routers/delivery_pickup.py @@ -0,0 +1,61 @@ +# Copyright 2019 Akretion (http://www.akretion.com). +# @author Sébastien BEAU +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +import logging +from typing import Annotated + +import requests +from fastapi import Depends, Request + +from odoo import _, api, models +from odoo.exceptions import Warning as UserError + +from odoo.addons.fastapi.dependencies import odoo_env +from odoo.addons.shopinvader_api_delivery_pickup.routers import delivery_pickup_router + +from ..schemas import DeliveryColissimoPickupToken + +_logger = logging.getLogger(__name__) + +LAPOSTE_API_ENDPOINT = "https://ws.colissimo.fr/widget-colissimo/rest/" + + +@delivery_pickup_router.get("/delivery_pickups/providers/colissimo/token") +def colissimo_token_return( + request: Request, + odoo_env: Annotated[api.Environment, Depends(odoo_env)], +) -> DeliveryColissimoPickupToken: + """ + Returns the token for Laposte Account. + + """ + login, password = odoo_env[ + "shopinvader_api_delivery_pickup_colissimo_widget_router.helper" + ]._get_laposte_account() + response = requests.post( + LAPOSTE_API_ENDPOINT + "authenticate.rest", + json={"login": login, "password": password}, + timeout=3600, + ) + if response.status_code == 200: + return response.json() + else: + _logger.error("La poste error %s %s", response.status_code, response.text) + raise UserError(_("Authentification Error with laposte")) + + +class ShopinvaderApiDeliveryColissimoRouterHelper(models.AbstractModel): + _name = "shopinvader_api_delivery_pickup_colissimo_widget_router.helper" + _description = "ShopInvader API Delivery Pickup Colissimo Router Helper" + + def _get_laposte_account(self): + login = self.env["ir.config_parameter"].get_param("laposte.user") + password = self.env["ir.config_parameter"].get_param("laposte.password") + if not login or not password: + raise UserError( + _( + "The login or password for your Laposte account " + "has not been entered in the system settings" + ) + ) + return login, password diff --git a/shopinvader_api_delivery_pickup_colissimo_widget/schemas/__init__.py b/shopinvader_api_delivery_pickup_colissimo_widget/schemas/__init__.py new file mode 100644 index 0000000..36c00a0 --- /dev/null +++ b/shopinvader_api_delivery_pickup_colissimo_widget/schemas/__init__.py @@ -0,0 +1 @@ +from .delivery_colissimo_pickup_token import DeliveryColissimoPickupToken diff --git a/shopinvader_api_delivery_pickup_colissimo_widget/schemas/delivery_colissimo_pickup_token.py b/shopinvader_api_delivery_pickup_colissimo_widget/schemas/delivery_colissimo_pickup_token.py new file mode 100644 index 0000000..9c359e5 --- /dev/null +++ b/shopinvader_api_delivery_pickup_colissimo_widget/schemas/delivery_colissimo_pickup_token.py @@ -0,0 +1,8 @@ +# Copyright 2024 Akretion +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from extendable_pydantic import StrictExtendableBaseModel + + +class DeliveryColissimoPickupToken(StrictExtendableBaseModel): + token: str diff --git a/shopinvader_api_delivery_pickup_colissimo_widget/static/description/index.html b/shopinvader_api_delivery_pickup_colissimo_widget/static/description/index.html new file mode 100644 index 0000000..583a756 --- /dev/null +++ b/shopinvader_api_delivery_pickup_colissimo_widget/static/description/index.html @@ -0,0 +1,428 @@ + + + + + +Shopinvader Pickup Colissimo + + + +
+

Shopinvader Pickup Colissimo

+ + +

Beta License: AGPL-3 shopinvader/odoo-shopinvader-carrier

+

This is shopinvader the odoo module for the new generation of e-commerce.

+

This module add the support of la poste dropoff site with the solution “Front PagePointRetrait”.

+

See documentation here: +.. _Front Page Point Relais: https://www.colissimo.entreprise.laposte.fr/fr/system/files/imagescontent/docs/FPPR-FR.pdf

+

Table of contents

+ +
+

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 to smash it by providing a detailed and welcomed +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Akretion
  • +
  • Shopinvader
  • +
+
+
+

Contributors

+ +
+
+

Other credits

+

The development of this module has been financially supported by:

+
    +
  • Akretion
  • +
+
+
+

Maintainers

+

This module is part of the shopinvader/odoo-shopinvader-carrier project on GitHub.

+

You are welcome to contribute.

+
+
+
+ + diff --git a/shopinvader_delivery_pickup_colissimo_widget/__init__.py b/shopinvader_delivery_pickup_colissimo_widget/__init__.py deleted file mode 100644 index 8ea8eab..0000000 --- a/shopinvader_delivery_pickup_colissimo_widget/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -# -*- coding: utf-8 -*- - -from . import services -from . import controllers diff --git a/shopinvader_delivery_pickup_colissimo_widget/controllers/__init__.py b/shopinvader_delivery_pickup_colissimo_widget/controllers/__init__.py deleted file mode 100644 index 12a7e52..0000000 --- a/shopinvader_delivery_pickup_colissimo_widget/controllers/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from . import main diff --git a/shopinvader_delivery_pickup_colissimo_widget/controllers/main.py b/shopinvader_delivery_pickup_colissimo_widget/controllers/main.py deleted file mode 100644 index 82a914d..0000000 --- a/shopinvader_delivery_pickup_colissimo_widget/controllers/main.py +++ /dev/null @@ -1,19 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2018 ACSONE Sa/ (http://www.acsone.eu) -# Cédric Pigeon -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - -import logging - -from odoo.addons.shopinvader.controllers import main -from odoo.http import route - -_logger = logging.getLogger(__name__) - - -class InvaderController(main.InvaderController): - @route(["/shopinvader/delivery_pickups/get_colissimo_pickup_token"], - methods=["GET"]) - def get_colissimo_pickup_token(self, **params): - return self._process_method( - "delivery_pickups", "get_colissimo_pickup_token", params) diff --git a/shopinvader_delivery_pickup_colissimo_widget/services/delivery_pickup.py b/shopinvader_delivery_pickup_colissimo_widget/services/delivery_pickup.py deleted file mode 100644 index e863e38..0000000 --- a/shopinvader_delivery_pickup_colissimo_widget/services/delivery_pickup.py +++ /dev/null @@ -1,48 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2019 Akretion (http://www.akretion.com). -# @author Sébastien BEAU -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - -import logging - -import requests -from odoo import _ -from odoo.addons.component.core import Component -from odoo.addons.delivery_roulier_laposte.models.keychain import ( - LAPOSTE_KEYCHAIN_NAMESPACE, -) -from odoo.exceptions import Warning as UserError - -_logger = logging.getLogger(__name__) - -LAPOSTE_API_ENDPOINT = "https://ws.colissimo.fr/widget-point-retrait/rest/" - - -class DeliveryPickupService(Component): - _inherit = "shopinvader.delivery.pickup.service" - - def get_colissimo_pickup_token(self): - login, password = self._get_laposte_account() - response = requests.post( - LAPOSTE_API_ENDPOINT + "authenticate.rest", - json={"login": login, "password": password}, - ) - if response.status_code == 200: - return response.json() - else: - _logger.error( - "La poste error %s %s", response.status_code, response.text - ) - raise UserError(_("Authentification Error with laposte")) - - def _get_laposte_account(self): - # Note for now we use keychain because the delivery module use it - # we will remove it later - account = self.env["keychain.account"]\ - .suspend_security()\ - .retrieve([["namespace", "=", LAPOSTE_KEYCHAIN_NAMESPACE]]) - return account.login, account._get_password() - - # Validator - def _validator_get_colissimo_pickup_token(self): - return {} diff --git a/shopinvader_delivery_pickup_colissimo_widget/tests/__init__.py b/shopinvader_delivery_pickup_colissimo_widget/tests/__init__.py deleted file mode 100644 index 5e88e05..0000000 --- a/shopinvader_delivery_pickup_colissimo_widget/tests/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -# -*- coding: utf-8 -*- - -from . import test_pickup_token diff --git a/shopinvader_delivery_pickup_colissimo_widget/tests/test_pickup_token.py b/shopinvader_delivery_pickup_colissimo_widget/tests/test_pickup_token.py deleted file mode 100644 index aeaf20e..0000000 --- a/shopinvader_delivery_pickup_colissimo_widget/tests/test_pickup_token.py +++ /dev/null @@ -1,23 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2019 Akretion (http://www.akretion.com). -# @author Sébastien BEAU -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - -import requests_mock -from odoo.addons.shopinvader.tests.common import CommonCase - - -class TokenCase(CommonCase): - def test_get_token(self): - account = self.env.ref('delivery_roulier_laposte.keychain_la_poste') - account.clear_password = "laposte_token" - with self.work_on_services() as work: - with requests_mock.mock() as m: - m.post( - "https://ws.colissimo.fr/widget-point-retrait" - "/rest/authenticate.rest", - json={"token": "laposte_token"}, - ) - service = work.component(usage="delivery_pickups") - res = service.dispatch("get_colissimo_pickup_token") - self.assertEqual(res, {"token": "laposte_token"}) From cab216c9dfded11d3e44718d94980940b11a489f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20BEAU?= Date: Tue, 3 Sep 2024 15:33:46 +0200 Subject: [PATCH 7/7] shopinvader_api_delivery_pickup_colissimo_widget: use sudo to retrieve laposte params --- .../routers/delivery_pickup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shopinvader_api_delivery_pickup_colissimo_widget/routers/delivery_pickup.py b/shopinvader_api_delivery_pickup_colissimo_widget/routers/delivery_pickup.py index 7ad1c3a..38fdd53 100644 --- a/shopinvader_api_delivery_pickup_colissimo_widget/routers/delivery_pickup.py +++ b/shopinvader_api_delivery_pickup_colissimo_widget/routers/delivery_pickup.py @@ -49,8 +49,8 @@ class ShopinvaderApiDeliveryColissimoRouterHelper(models.AbstractModel): _description = "ShopInvader API Delivery Pickup Colissimo Router Helper" def _get_laposte_account(self): - login = self.env["ir.config_parameter"].get_param("laposte.user") - password = self.env["ir.config_parameter"].get_param("laposte.password") + login = self.env["ir.config_parameter"].sudo().get_param("laposte.user") + password = self.env["ir.config_parameter"].sudo().get_param("laposte.password") if not login or not password: raise UserError( _(