Skip to content

Commit

Permalink
[17.0][MIG] delivery_roulier: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
yankinmax committed Jun 18, 2024
1 parent b84b528 commit c98ece8
Show file tree
Hide file tree
Showing 20 changed files with 155 additions and 118 deletions.
77 changes: 40 additions & 37 deletions delivery_roulier/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ Delivery Carrier Roulier
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fdelivery--carrier-lightgray.png?logo=github
:target: https://github.com/OCA/delivery-carrier/tree/16.0/delivery_roulier
:target: https://github.com/OCA/delivery-carrier/tree/17.0/delivery_roulier
:alt: OCA/delivery-carrier
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/delivery-carrier-16-0/delivery-carrier-16-0-delivery_roulier
:target: https://translation.odoo-community.org/projects/delivery-carrier-17-0/delivery-carrier-17-0-delivery_roulier
: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/delivery-carrier&target_branch=16.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/delivery-carrier&target_branch=17.0
:alt: Try me on Runboat

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

Base module for integration with Roulier.

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

You should install one of the specific modules :

- delivery_roulier_laposte
- delivery_roulier_dpd
- delivery_roulier_geodis
- delivery_carrier_label_gls
- more to come
- delivery_roulier_laposte
- delivery_roulier_dpd
- delivery_roulier_geodis
- delivery_carrier_label_gls
- more to come

**Table of contents**

Expand All @@ -51,79 +52,81 @@ You should install one of the specific modules :
Configuration
=============

This module needs package in order to work.
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.
This module needs package in order to work. 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.

Usage
=====

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

.. code-block:: python
.. code:: python
def _mycarrier_get_sender(...):
def _mycarrier_get_sender(...):
def _mycarrier_get_receiver(...):
def _mycarrier_get_receiver(...):
def _mycarrier_get_shipping_date(...):
def _mycarrier_get_shipping_date(...):
def _mycarrier_get_account(...):
def _mycarrier_get_account(...):
def _mycarrier_get_auth(...):
def _mycarrier_get_auth(...):
def _mycarrier_get_service(...):
def _mycarrier_get_service(...):
def _mycarrier_convert_address(...):
def _mycarrier_convert_address(...):
Instead of calling super() you can use:

|
.. code:: python
def _mycarrier_get_service(...):
Instead of calling `super()` you can use:
result = _roulier_get_service(...)
.. code-block:: python
result["specific_key"] = "blabla"
def _mycarrier_get_service(...):
result = _roulier_get_service(...)
result["specific_key"] = "blabla"
return result
return result
Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/delivery-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/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**>`_.
`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**>`_.

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

Credits
=======

Authors
~~~~~~~
-------

* Akretion

Contributors
~~~~~~~~~~~~
------------

* Raphaël Reverdy <sebastien.beau@akretion.com>
* David Béal <david.beal@akretion.com>
- Raphaël Reverdy <sebastien.beau@akretion.com>
- David Béal <david.beal@akretion.com>

Maintainers
~~~~~~~~~~~
-----------

This module is maintained by the OCA.

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

|maintainer-florian-dacosta|

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

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 2 additions & 1 deletion delivery_roulier/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Delivery Carrier Roulier",
"version": "16.0.1.0.0",
"version": "17.0.1.0.0",
"author": "Akretion,Odoo Community Association (OCA)",
"summary": "Integration of multiple carriers",
"maintainers": ["florian-dacosta"],
Expand All @@ -20,6 +20,7 @@
"external_dependencies": {
"python": [
"roulier", # '>0.2.0'
"odoo_test_helper",
],
},
"installable": True,
Expand Down
2 changes: 1 addition & 1 deletion delivery_roulier/decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def get_delivery_type(cls, *args, **kwargs):
return cls[0].carrier_id.delivery_type

Check warning on line 34 in delivery_roulier/decorator.py

View check run for this annotation

Codecov / codecov/patch

delivery_roulier/decorator.py#L34

Added line #L34 was not covered by tests

delivery_type = get_delivery_type(cls, *args, **kwargs)
fun = "_{}{}".format(delivery_type, fun_name)
fun = f"_{delivery_type}{fun_name}"
if not hasattr(cls, fun):
fun = "_roulier%s" % (fun_name)
return getattr(cls, fun)(*args, **kwargs)
Expand Down
2 changes: 1 addition & 1 deletion delivery_roulier/i18n/delivery_roulier.pot
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Project-Id-Version: Odoo Server 17.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
Expand Down
2 changes: 1 addition & 1 deletion delivery_roulier/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Project-Id-Version: Odoo Server 17.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-10-09 18:14+0000\n"
"Last-Translator: Ivorra78 <informatica@totmaterial.es>\n"
Expand Down
2 changes: 1 addition & 1 deletion delivery_roulier/i18n/it.po
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Project-Id-Version: Odoo Server 17.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2024-05-07 12:35+0000\n"
"Last-Translator: mymage <stefano.consolaro@mymage.it>\n"
Expand Down
15 changes: 15 additions & 0 deletions delivery_roulier/models/stock_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,18 @@ def get_unit_price_for_customs(self):
def get_sale_order_line(self):
self.ensure_one()
return self.move_id.sale_line_id

Check warning on line 41 in delivery_roulier/models/stock_move_line.py

View check run for this annotation

Codecov / codecov/patch

delivery_roulier/models/stock_move_line.py#L40-L41

Added lines #L40 - L41 were not covered by tests

def write(self, vals):
# OVERRIDE to set `quant_id` if `result_package_id` is set
# during `stock.picking`::`_put_in_pack` call
if "result_package_id" in vals:
for move_line in self.filtered(lambda s: not s.result_package_id):
quants_by_product = self.env[
"stock.quant"
]._get_quants_by_products_locations(
move_line.product_id, move_line.location_id
)
if not quants_by_product or len(quants_by_product) > 1:
continue

Check warning on line 54 in delivery_roulier/models/stock_move_line.py

View check run for this annotation

Codecov / codecov/patch

delivery_roulier/models/stock_move_line.py#L54

Added line #L54 was not covered by tests
vals["quant_id"] = quants_by_product.get(move_line.product_id.id).id
return super().write(vals)
11 changes: 10 additions & 1 deletion delivery_roulier/models/stock_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def _roulier_generate_labels(self):
label_info = []
for picking in self:
move_line_no_pack = picking.move_line_ids.filtered(
lambda ml: ml.qty_done > 0.0 and not ml.result_package_id
lambda ml: ml.quantity > 0.0 and not ml.result_package_id
)
if move_line_no_pack:
raise UserError(

Check warning on line 90 in delivery_roulier/models/stock_picking.py

View check run for this annotation

Codecov / codecov/patch

delivery_roulier/models/stock_picking.py#L90

Added line #L90 was not covered by tests
Expand Down Expand Up @@ -290,3 +290,12 @@ def open_website_url(self):
action["domain"] = [("id", "in", packages.ids)]
action["context"] = {"picking_id": self.id}
return action

Check warning on line 292 in delivery_roulier/models/stock_picking.py

View check run for this annotation

Codecov / codecov/patch

delivery_roulier/models/stock_picking.py#L288-L292

Added lines #L288 - L292 were not covered by tests

def _put_in_pack(self, move_line_ids):
# OVERRIDE to propagate `quant_ids`
# after `result_package_id` is set on the move line
package = super()._put_in_pack(move_line_ids)
for move in move_line_ids:
if move.quant_id:
package.quant_ids |= move.quant_id
return package
15 changes: 6 additions & 9 deletions delivery_roulier/models/stock_quant_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,24 +112,22 @@ def _roulier_parse_response(self, picking, response):
# find for which package the label is. tracking number will be updated on
# this pack later on (in base_delivery_carrier_label)
package_id = False
ref = parcel.get("reference")
if len(self) == 1:
package_id = self.id
else:
pack = self.filtered(lambda p: p.name == parcel.get("reference"))
pack = self.filtered(lambda p, ref=ref: p.name == ref)
if len(pack) == 1:
package_id = pack.id

Check warning on line 121 in delivery_roulier/models/stock_quant_package.py

View check run for this annotation

Codecov / codecov/patch

delivery_roulier/models/stock_quant_package.py#L121

Added line #L121 was not covered by tests

name_prefix = ref or tracking_number or label.get("name")
name_suffix = label.get("type", "").lower()
parcels_data.append(
{
"tracking_number": tracking_number,
"parcel_tracking_uri": parcel.get("tracking", {}).get("url", False),
"package_id": package_id,
"file": label.get("data"),
"name": "%s.%s"
% (
parcel.get("reference") or tracking_number or label.get("name"),
label.get("type", "").lower(),
),
"name": f"{name_prefix}.{name_suffix}",
"file_type": label.get("type"),
}
)
Expand Down Expand Up @@ -287,8 +285,7 @@ def _roulier_prepare_attachments(self, picking, response):
"res_model": "stock.picking",
"datas": attachment["data"],
"type": "binary",
"name": "%s-%s.%s"
% (self.name, attachment["name"], attachment["type"]),
"name": f"{self.name}-{attachment['name']}.{attachment['type']}",
}
for attachment in attachments
]
3 changes: 3 additions & 0 deletions delivery_roulier/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
8 changes: 8 additions & 0 deletions delivery_roulier/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
This module needs package in order to work. 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.
2 changes: 0 additions & 2 deletions delivery_roulier/readme/CONFIGURE.rst

This file was deleted.

2 changes: 2 additions & 0 deletions delivery_roulier/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Raphaël Reverdy \<<sebastien.beau@akretion.com>\>
- David Béal \<<david.beal@akretion.com>\>
2 changes: 0 additions & 2 deletions delivery_roulier/readme/CONTRIBUTORS.rst

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ Integration of multiple carriers with Roulier library

Base module for integration with Roulier.

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

You should install one of the specific modules :

Expand Down
36 changes: 36 additions & 0 deletions delivery_roulier/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
Here is some methods you can use for your carrier implementation
allowing to have a consistent code accross different carrier modules:

``` python
def _mycarrier_get_sender(...):


def _mycarrier_get_receiver(...):


def _mycarrier_get_shipping_date(...):


def _mycarrier_get_account(...):


def _mycarrier_get_auth(...):


def _mycarrier_get_service(...):


def _mycarrier_convert_address(...):
```

Instead of calling super() you can use:

``` python
def _mycarrier_get_service(...):

result = _roulier_get_service(...)

result["specific_key"] = "blabla"

return result
```
Loading

0 comments on commit c98ece8

Please sign in to comment.