Skip to content

Commit e569ac5

Browse files
committed
[17.0][MIG] delivery_roulier: Migration to 17.0
1 parent b832460 commit e569ac5

20 files changed

+156
-118
lines changed

delivery_roulier/README.rst

+40-37
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ Delivery Carrier Roulier
1717
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
1818
:alt: License: AGPL-3
1919
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fdelivery--carrier-lightgray.png?logo=github
20-
:target: https://github.com/OCA/delivery-carrier/tree/16.0/delivery_roulier
20+
:target: https://github.com/OCA/delivery-carrier/tree/17.0/delivery_roulier
2121
:alt: OCA/delivery-carrier
2222
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23-
:target: https://translation.odoo-community.org/projects/delivery-carrier-16-0/delivery-carrier-16-0-delivery_roulier
23+
:target: https://translation.odoo-community.org/projects/delivery-carrier-17-0/delivery-carrier-17-0-delivery_roulier
2424
:alt: Translate me on Weblate
2525
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26-
:target: https://runboat.odoo-community.org/builds?repo=OCA/delivery-carrier&target_branch=16.0
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/delivery-carrier&target_branch=17.0
2727
:alt: Try me on Runboat
2828

2929
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -32,16 +32,17 @@ Integration of multiple carriers with Roulier library
3232

3333
Base module for integration with Roulier.
3434

35-
`Roulier <https://pypi.python.org/pypi/roulier>`_ is a python library which implements carriers API.
36-
This modules contains the core functions for this implementation.
35+
`Roulier <https://pypi.python.org/pypi/roulier>`__ is a python library
36+
which implements carriers API. This modules contains the core functions
37+
for this implementation.
3738

3839
You should install one of the specific modules :
3940

40-
- delivery_roulier_laposte
41-
- delivery_roulier_dpd
42-
- delivery_roulier_geodis
43-
- delivery_carrier_label_gls
44-
- more to come
41+
- delivery_roulier_laposte
42+
- delivery_roulier_dpd
43+
- delivery_roulier_geodis
44+
- delivery_carrier_label_gls
45+
- more to come
4546

4647
**Table of contents**
4748

@@ -51,79 +52,81 @@ You should install one of the specific modules :
5152
Configuration
5253
=============
5354

54-
This module needs package in order to work.
55-
To generate the carrier labels on the picking, each products need to be assigned to a destination package. In case you don't want to bother with the use of package because the whole content of the picking usually fit in a unique package, you may consider installing the module delivery_automatic_package from the same repository (delivery-carrier). The package will be assigned automatically when asking the carrier labels.
55+
This module needs package in order to work. To generate the carrier
56+
labels on the picking, each products need to be assigned to a
57+
destination package. In case you don't want to bother with the use of
58+
package because the whole content of the picking usually fit in a unique
59+
package, you may consider installing the module
60+
delivery_automatic_package from the same repository (delivery-carrier).
61+
The package will be assigned automatically when asking the carrier
62+
labels.
5663

5764
Usage
5865
=====
5966

6067
Here is some methods you can use for your carrier implementation
6168
allowing to have a consistent code accross different carrier modules:
6269

63-
.. code-block:: python
70+
.. code:: python
6471
65-
def _mycarrier_get_sender(...):
72+
def _mycarrier_get_sender(...):
6673
6774
68-
def _mycarrier_get_receiver(...):
75+
def _mycarrier_get_receiver(...):
6976
7077
71-
def _mycarrier_get_shipping_date(...):
78+
def _mycarrier_get_shipping_date(...):
7279
7380
74-
def _mycarrier_get_account(...):
81+
def _mycarrier_get_account(...):
7582
7683
77-
def _mycarrier_get_auth(...):
84+
def _mycarrier_get_auth(...):
7885
7986
80-
def _mycarrier_get_service(...):
87+
def _mycarrier_get_service(...):
8188
8289
83-
def _mycarrier_convert_address(...):
90+
def _mycarrier_convert_address(...):
8491
92+
Instead of calling super() you can use:
8593

86-
|
94+
.. code:: python
8795
96+
def _mycarrier_get_service(...):
8897
89-
Instead of calling `super()` you can use:
98+
result = _roulier_get_service(...)
9099
91-
.. code-block:: python
100+
result["specific_key"] = "blabla"
92101
93-
def _mycarrier_get_service(...):
94-
95-
result = _roulier_get_service(...)
96-
97-
result["specific_key"] = "blabla"
98-
99-
return result
102+
return result
100103
101104
Bug Tracker
102105
===========
103106

104107
Bugs are tracked on `GitHub Issues <https://github.com/OCA/delivery-carrier/issues>`_.
105108
In case of trouble, please check there if your issue has already been reported.
106109
If you spotted it first, help us to smash it by providing a detailed and welcomed
107-
`feedback <https://github.com/OCA/delivery-carrier/issues/new?body=module:%20delivery_roulier%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
110+
`feedback <https://github.com/OCA/delivery-carrier/issues/new?body=module:%20delivery_roulier%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
108111

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

111114
Credits
112115
=======
113116

114117
Authors
115-
~~~~~~~
118+
-------
116119

117120
* Akretion
118121

119122
Contributors
120-
~~~~~~~~~~~~
123+
------------
121124

122-
* Raphaël Reverdy <sebastien.beau@akretion.com>
123-
* David Béal <david.beal@akretion.com>
125+
- Raphaël Reverdy <sebastien.beau@akretion.com>
126+
- David Béal <david.beal@akretion.com>
124127

125128
Maintainers
126-
~~~~~~~~~~~
129+
-----------
127130

128131
This module is maintained by the OCA.
129132

@@ -143,6 +146,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
143146

144147
|maintainer-florian-dacosta|
145148

146-
This module is part of the `OCA/delivery-carrier <https://github.com/OCA/delivery-carrier/tree/16.0/delivery_roulier>`_ project on GitHub.
149+
This module is part of the `OCA/delivery-carrier <https://github.com/OCA/delivery-carrier/tree/17.0/delivery_roulier>`_ project on GitHub.
147150

148151
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

delivery_roulier/__manifest__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
44
{
55
"name": "Delivery Carrier Roulier",
6-
"version": "16.0.1.0.0",
6+
"version": "17.0.1.0.0",
77
"author": "Akretion,Odoo Community Association (OCA)",
88
"summary": "Integration of multiple carriers",
99
"maintainers": ["florian-dacosta"],
@@ -20,6 +20,7 @@
2020
"external_dependencies": {
2121
"python": [
2222
"roulier", # '>0.2.0'
23+
"odoo_test_helper",
2324
],
2425
},
2526
"installable": True,

delivery_roulier/decorator.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def get_delivery_type(cls, *args, **kwargs):
3434
return cls[0].carrier_id.delivery_type
3535

3636
delivery_type = get_delivery_type(cls, *args, **kwargs)
37-
fun = "_{}{}".format(delivery_type, fun_name)
37+
fun = f"_{delivery_type}{fun_name}"
3838
if not hasattr(cls, fun):
3939
fun = "_roulier%s" % (fun_name)
4040
return getattr(cls, fun)(*args, **kwargs)

delivery_roulier/i18n/delivery_roulier.pot

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
msgid ""
66
msgstr ""
7-
"Project-Id-Version: Odoo Server 16.0\n"
7+
"Project-Id-Version: Odoo Server 17.0\n"
88
"Report-Msgid-Bugs-To: \n"
99
"Last-Translator: \n"
1010
"Language-Team: \n"

delivery_roulier/i18n/es.po

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
msgid ""
66
msgstr ""
7-
"Project-Id-Version: Odoo Server 16.0\n"
7+
"Project-Id-Version: Odoo Server 17.0\n"
88
"Report-Msgid-Bugs-To: \n"
99
"PO-Revision-Date: 2023-10-09 18:14+0000\n"
1010
"Last-Translator: Ivorra78 <informatica@totmaterial.es>\n"

delivery_roulier/i18n/it.po

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
msgid ""
66
msgstr ""
7-
"Project-Id-Version: Odoo Server 16.0\n"
7+
"Project-Id-Version: Odoo Server 17.0\n"
88
"Report-Msgid-Bugs-To: \n"
99
"PO-Revision-Date: 2024-05-07 12:35+0000\n"
1010
"Last-Translator: mymage <stefano.consolaro@mymage.it>\n"

delivery_roulier/models/stock_move_line.py

+15
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,18 @@ def get_unit_price_for_customs(self):
3939
def get_sale_order_line(self):
4040
self.ensure_one()
4141
return self.move_id.sale_line_id
42+
43+
def write(self, vals):
44+
# OVERRIDE to set `quant_id` if `result_package_id` is set
45+
# during `stock.picking`::`_put_in_pack` call
46+
if "result_package_id" in vals:
47+
for move_line in self.filtered(lambda s: not s.result_package_id):
48+
quants_by_product = self.env[
49+
"stock.quant"
50+
]._get_quants_by_products_locations(
51+
move_line.product_id, move_line.location_id
52+
)
53+
if not quants_by_product or len(quants_by_product) > 1:
54+
continue
55+
vals["quant_id"] = quants_by_product.get(move_line.product_id.id).id
56+
return super().write(vals)

delivery_roulier/models/stock_picking.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def _roulier_generate_labels(self):
8484
label_info = []
8585
for picking in self:
8686
move_line_no_pack = picking.move_line_ids.filtered(
87-
lambda ml: ml.qty_done > 0.0 and not ml.result_package_id
87+
lambda ml: ml.quantity > 0.0 and not ml.result_package_id
8888
)
8989
if move_line_no_pack:
9090
raise UserError(
@@ -290,3 +290,12 @@ def open_website_url(self):
290290
action["domain"] = [("id", "in", packages.ids)]
291291
action["context"] = {"picking_id": self.id}
292292
return action
293+
294+
def _put_in_pack(self, move_line_ids):
295+
# OVERRIDE to propagate `quant_ids`
296+
# after `result_package_id` is set on the move line
297+
package = super()._put_in_pack(move_line_ids)
298+
for move in move_line_ids:
299+
if move.quant_id:
300+
package.quant_ids |= move.quant_id
301+
return package

delivery_roulier/models/stock_quant_package.py

+6-9
Original file line numberDiff line numberDiff line change
@@ -112,24 +112,22 @@ def _roulier_parse_response(self, picking, response):
112112
# find for which package the label is. tracking number will be updated on
113113
# this pack later on (in base_delivery_carrier_label)
114114
package_id = False
115+
ref = parcel.get("reference")
115116
if len(self) == 1:
116117
package_id = self.id
117118
else:
118-
pack = self.filtered(lambda p: p.name == parcel.get("reference"))
119+
pack = self.filtered(lambda p, ref=ref: p.name == ref)
119120
if len(pack) == 1:
120121
package_id = pack.id
121-
122+
name_prefix = ref or tracking_number or label.get("name")
123+
name_suffix = label.get("type", "").lower()
122124
parcels_data.append(
123125
{
124126
"tracking_number": tracking_number,
125127
"parcel_tracking_uri": parcel.get("tracking", {}).get("url", False),
126128
"package_id": package_id,
127129
"file": label.get("data"),
128-
"name": "%s.%s"
129-
% (
130-
parcel.get("reference") or tracking_number or label.get("name"),
131-
label.get("type", "").lower(),
132-
),
130+
"name": f"{name_prefix}.{name_suffix}",
133131
"file_type": label.get("type"),
134132
}
135133
)
@@ -287,8 +285,7 @@ def _roulier_prepare_attachments(self, picking, response):
287285
"res_model": "stock.picking",
288286
"datas": attachment["data"],
289287
"type": "binary",
290-
"name": "%s-%s.%s"
291-
% (self.name, attachment["name"], attachment["type"]),
288+
"name": f"{self.name}-{attachment['name']}.{attachment['type']}",
292289
}
293290
for attachment in attachments
294291
]

delivery_roulier/pyproject.toml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["whool"]
3+
build-backend = "whool.buildapi"

delivery_roulier/readme/CONFIGURE.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
This module needs package in order to work. To generate the carrier
2+
labels on the picking, each products need to be assigned to a
3+
destination package. In case you don't want to bother with the use of
4+
package because the whole content of the picking usually fit in a unique
5+
package, you may consider installing the module
6+
delivery_automatic_package from the same repository (delivery-carrier).
7+
The package will be assigned automatically when asking the carrier
8+
labels.

delivery_roulier/readme/CONFIGURE.rst

-2
This file was deleted.
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- Raphaël Reverdy \<<sebastien.beau@akretion.com>\>
2+
- David Béal \<<david.beal@akretion.com>\>

delivery_roulier/readme/CONTRIBUTORS.rst

-2
This file was deleted.

delivery_roulier/readme/DESCRIPTION.rst delivery_roulier/readme/DESCRIPTION.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ Integration of multiple carriers with Roulier library
22

33
Base module for integration with Roulier.
44

5-
`Roulier <https://pypi.python.org/pypi/roulier>`_ is a python library which implements carriers API.
6-
This modules contains the core functions for this implementation.
5+
[Roulier](https://pypi.python.org/pypi/roulier) is a python library
6+
which implements carriers API. This modules contains the core functions
7+
for this implementation.
78

89
You should install one of the specific modules :
910

delivery_roulier/readme/USAGE.md

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
Here is some methods you can use for your carrier implementation
2+
allowing to have a consistent code accross different carrier modules:
3+
4+
``` python
5+
def _mycarrier_get_sender(...):
6+
7+
8+
def _mycarrier_get_receiver(...):
9+
10+
11+
def _mycarrier_get_shipping_date(...):
12+
13+
14+
def _mycarrier_get_account(...):
15+
16+
17+
def _mycarrier_get_auth(...):
18+
19+
20+
def _mycarrier_get_service(...):
21+
22+
23+
def _mycarrier_convert_address(...):
24+
```
25+
26+
Instead of calling super() you can use:
27+
28+
``` python
29+
def _mycarrier_get_service(...):
30+
31+
result = _roulier_get_service(...)
32+
33+
result["specific_key"] = "blabla"
34+
35+
return result
36+
```

0 commit comments

Comments
 (0)