Skip to content

Commit a2d06f2

Browse files
[16.0][MIG] shopinvader_delivery_pickup_colissimo_widget
1 parent e961c84 commit a2d06f2

File tree

22 files changed

+627
-109
lines changed

22 files changed

+627
-109
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# addons listed in this file are ignored by
2+
# setuptools-odoo-make-default (one addon per line)

setup/README

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
To learn more about this directory, please visit
2+
https://pypi.python.org/pypi/setuptools-odoo
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../shopinvader_api_delivery_pickup_colissimo_widget
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import setuptools
2+
3+
setuptools.setup(
4+
setup_requires=['setuptools-odoo'],
5+
odoo_addon=True,
6+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
============================
2+
Shopinvader Pickup Colissimo
3+
============================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:33018a07e970ac37422c211d6868173b5d18970b11eef184ca9f565876e50d42
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Beta
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
18+
:alt: License: AGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-shopinvader%2Fodoo--shopinvader--carrier-lightgray.png?logo=github
20+
:target: https://github.com/shopinvader/odoo-shopinvader-carrier/tree/16.0/shopinvader_api_delivery_pickup_colissimo_widget
21+
:alt: shopinvader/odoo-shopinvader-carrier
22+
23+
|badge1| |badge2| |badge3|
24+
25+
This is shopinvader the odoo module for the new generation of e-commerce.
26+
27+
This module add the support of la poste dropoff site with the solution "Front PagePointRetrait".
28+
29+
See documentation here:
30+
.. _Front Page Point Relais: https://www.colissimo.entreprise.laposte.fr/fr/system/files/imagescontent/docs/FPPR-FR.pdf
31+
32+
33+
.. _Shopinvader: https://shopinvader.com
34+
35+
**Table of contents**
36+
37+
.. contents::
38+
:local:
39+
40+
Bug Tracker
41+
===========
42+
43+
Bugs are tracked on `GitHub Issues <https://github.com/shopinvader/odoo-shopinvader-carrier/issues>`_.
44+
In case of trouble, please check there if your issue has already been reported.
45+
If you spotted it first, help us to smash it by providing a detailed and welcomed
46+
`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**>`_.
47+
48+
Do not contact contributors directly about support or help with technical issues.
49+
50+
Credits
51+
=======
52+
53+
Authors
54+
~~~~~~~
55+
56+
* Akretion
57+
* Shopinvader
58+
59+
Contributors
60+
~~~~~~~~~~~~
61+
62+
* Sebastien BEAU <[email protected]>
63+
* Chafique DELLI <[email protected]>
64+
65+
Other credits
66+
~~~~~~~~~~~~~
67+
68+
The development of this module has been financially supported by:
69+
70+
* Akretion
71+
72+
Maintainers
73+
~~~~~~~~~~~
74+
75+
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.
76+
77+
You are welcome to contribute.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import routers
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
# -*- coding: utf-8 -*-
21
# Copyright 2019 Akretion (http://www.akretion.com)
32
# Sébastien BEAU <[email protected]>
43
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
54

65
{
7-
"name": "Shopinvader Dropoff site Public Edition",
8-
"summary": "Shopinvader Dropoff site Public Edition",
9-
"version": "10.0.0.0.0",
6+
"name": "Shopinvader Pickup Colissimo",
7+
"summary": "Shopinvader Pickup Colissimo",
8+
"version": "16.0.1.0.0",
109
"category": "e-commerce",
11-
"website": "https://akretion.com",
12-
"author": "Akretion",
10+
"website": "https://github.com/shopinvader/odoo-shopinvader-carrier",
11+
"author": "Akretion, Shopinvader",
1312
"license": "AGPL-3",
1413
"application": False,
1514
"installable": True,
1615
"external_dependencies": {"python": [], "bin": []},
1716
"depends": [
18-
"shopinvader_delivery_pickup_public_edition",
19-
"delivery_roulier_laposte",
17+
"shopinvader_api_delivery_pickup_public_edition",
18+
],
19+
"data": [
20+
"data/ir_config_parameter_data.xml",
2021
],
21-
"data": [],
2222
"demo": [],
2323
"qweb": [],
2424
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<odoo noupdate="1">
3+
4+
<!-- Login for Laposte Account -->
5+
<record id="laposte_account_user" model="ir.config_parameter">
6+
<field name="key">laposte.user</field>
7+
<field name="value" />
8+
</record>
9+
<!-- Password for Laposte Account -->
10+
<record id="laposte_account_password" model="ir.config_parameter">
11+
<field name="key">laposte.password</field>
12+
<field name="value" />
13+
</record>
14+
15+
</odoo>
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
* Sebastien BEAU <[email protected]>
2+
* Chafique DELLI <[email protected]>
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
# -*- coding: utf-8 -*-
2-
31
from . import delivery_pickup
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Copyright 2019 Akretion (http://www.akretion.com).
2+
# @author Sébastien BEAU <[email protected]>
3+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
4+
import logging
5+
from typing import Annotated
6+
7+
import requests
8+
from fastapi import APIRouter, Depends, Request
9+
10+
from odoo import _, api, models
11+
from odoo.exceptions import Warning as UserError
12+
13+
from odoo.addons.fastapi.dependencies import odoo_env
14+
15+
_logger = logging.getLogger(__name__)
16+
17+
LAPOSTE_API_ENDPOINT = "https://ws.colissimo.fr/widget-point-retrait/rest/"
18+
19+
from ..schemas import DeliveryColissimoPickupToken as DeliveryColissimoPickupTokenSchema
20+
21+
delivery_colissimo_pickup_token_router = APIRouter(
22+
tags=["delivery_colissimo_pickup_token"]
23+
)
24+
25+
26+
@delivery_colissimo_pickup_token_router.get(
27+
"/delivery_carrier/provider/collissimo/token "
28+
)
29+
def get_colissimo_pickup_token(
30+
request: Request,
31+
odoo_env: Annotated[api.Environment, Depends(odoo_env)],
32+
) -> list[DeliveryColissimoPickupTokenSchema]:
33+
"""
34+
Returns the token for Laposte Account.
35+
36+
"""
37+
login, password = odoo_env[
38+
"shopinvader_api_delivery_pickup_colissimo_widget.delivery_pickup_colissimo_router.helper"
39+
]._get_laposte_account()
40+
response = requests.post(
41+
LAPOSTE_API_ENDPOINT + "authenticate.rest",
42+
json={"login": login, "password": password},
43+
timeout=3600,
44+
)
45+
if response.status_code == 200:
46+
return response.json()
47+
else:
48+
_logger.error("La poste error %s %s", response.status_code, response.text)
49+
raise UserError(_("Authentification Error with laposte"))
50+
51+
52+
class ShopinvaderApiDeliveryRouterHelper(models.AbstractModel):
53+
_name = "shopinvader_api_delivery_pickup_colissimo_widget.delivery_pickup_colissimo_router.helper"
54+
_description = "ShopInvader API Delivery Pickup Colissimo Router Helper"
55+
56+
def _get_laposte_account(self):
57+
login = self.env["ir.config_parameter"].get_param("laposte.user")
58+
password = self.env["ir.config_parameter"].get_param("laposte.password")
59+
if not login or not password:
60+
raise UserError(
61+
_(
62+
"The login or password for your Laposte account "
63+
"has not been entered in the system settings"
64+
)
65+
)
66+
return login, password
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from .delivery_colissimo_pickup_token import (
2+
DeliveryPickup,
3+
DeliveryPickupInput,
4+
DeliveryPickupSearch,
5+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Copyright 2024 Akretion
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
3+
4+
from extendable_pydantic import StrictExtendableBaseModel
5+
6+
7+
class DeliveryColissimoPickupToken(StrictExtendableBaseModel):
8+
token: str
9+
10+
@classmethod
11+
def from_delivery_colissimo_pickup_token(cls, odoo_rec):
12+
return cls.model_construct(
13+
token=odoo_rec.token,
14+
)

0 commit comments

Comments
 (0)