Skip to content

Commit

Permalink
[16.0][MIG] shopinvader_delivery_pickup_colissimo_widget
Browse files Browse the repository at this point in the history
  • Loading branch information
chafique-delli committed Aug 26, 2024
1 parent e961c84 commit e6126bf
Show file tree
Hide file tree
Showing 22 changed files with 612 additions and 109 deletions.
2 changes: 2 additions & 0 deletions setup/.setuptools-odoo-make-default-ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# addons listed in this file are ignored by
# setuptools-odoo-make-default (one addon per line)
2 changes: 2 additions & 0 deletions setup/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
To learn more about this directory, please visit
https://pypi.python.org/pypi/setuptools-odoo
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,
)
77 changes: 77 additions & 0 deletions shopinvader_api_delivery_pickup_colissimo_widget/README.rst
Original file line number Diff line number Diff line change
@@ -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 <https://github.com/shopinvader/odoo-shopinvader-carrier/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/shopinvader/odoo-shopinvader-carrier/issues/new?body=module:%20shopinvader_api_delivery_pickup_colissimo_widget%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
~~~~~~~

* Akretion
* Shopinvader

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

* Sebastien BEAU <[email protected]>
* Chafique DELLI <[email protected]>

Other credits
~~~~~~~~~~~~~

The development of this module has been financially supported by:

* Akretion

Maintainers
~~~~~~~~~~~

This module is part of the `shopinvader/odoo-shopinvader-carrier <https://github.com/shopinvader/odoo-shopinvader-carrier/tree/16.0/shopinvader_api_delivery_pickup_colissimo_widget>`_ project on GitHub.

You are welcome to contribute.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import routers
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
# -*- coding: utf-8 -*-
# Copyright 2019 Akretion (http://www.akretion.com)
# Sébastien BEAU <[email protected]>
# 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": [],
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1">

<!-- Login for Laposte Account -->
<record id="laposte_account_user" model="ir.config_parameter">
<field name="key">laposte.user</field>
<field name="value" />
</record>
<!-- Password for Laposte Account -->
<record id="laposte_account_password" model="ir.config_parameter">
<field name="key">laposte.password</field>
<field name="value" />
</record>

</odoo>
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
* Sebastien BEAU <[email protected]>
* Chafique DELLI <[email protected]>
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
# -*- coding: utf-8 -*-

from . import delivery_pickup
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Copyright 2019 Akretion (http://www.akretion.com).
# @author Sébastien BEAU <[email protected]>
# 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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .delivery_colissimo_pickup_token import DeliveryColissimoPickupToken
Original file line number Diff line number Diff line change
@@ -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
Loading

0 comments on commit e6126bf

Please sign in to comment.