From c98ece8a9a3bb55d00ef8222a5412d27f7766157 Mon Sep 17 00:00:00 2001 From: Maksym Yankin Date: Tue, 4 Jun 2024 19:27:58 +0300 Subject: [PATCH] [17.0][MIG] delivery_roulier: Migration to 17.0 --- delivery_roulier/README.rst | 77 ++++++++++--------- delivery_roulier/__manifest__.py | 3 +- delivery_roulier/decorator.py | 2 +- delivery_roulier/i18n/delivery_roulier.pot | 2 +- delivery_roulier/i18n/es.po | 2 +- delivery_roulier/i18n/it.po | 2 +- delivery_roulier/models/stock_move_line.py | 15 ++++ delivery_roulier/models/stock_picking.py | 11 ++- .../models/stock_quant_package.py | 15 ++-- delivery_roulier/pyproject.toml | 3 + delivery_roulier/readme/CONFIGURE.md | 8 ++ delivery_roulier/readme/CONFIGURE.rst | 2 - delivery_roulier/readme/CONTRIBUTORS.md | 2 + delivery_roulier/readme/CONTRIBUTORS.rst | 2 - .../{DESCRIPTION.rst => DESCRIPTION.md} | 5 +- delivery_roulier/readme/USAGE.md | 36 +++++++++ delivery_roulier/readme/USAGE.rst | 40 ---------- .../static/description/index.html | 38 +++++---- .../tests/test_delivery_roulier.py | 5 +- requirements.txt | 3 + 20 files changed, 155 insertions(+), 118 deletions(-) create mode 100644 delivery_roulier/pyproject.toml create mode 100644 delivery_roulier/readme/CONFIGURE.md delete mode 100644 delivery_roulier/readme/CONFIGURE.rst create mode 100644 delivery_roulier/readme/CONTRIBUTORS.md delete mode 100644 delivery_roulier/readme/CONTRIBUTORS.rst rename delivery_roulier/readme/{DESCRIPTION.rst => DESCRIPTION.md} (61%) create mode 100644 delivery_roulier/readme/USAGE.md delete mode 100644 delivery_roulier/readme/USAGE.rst create mode 100644 requirements.txt diff --git a/delivery_roulier/README.rst b/delivery_roulier/README.rst index 43c6012edd..ada9f156f5 100644 --- a/delivery_roulier/README.rst +++ b/delivery_roulier/README.rst @@ -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| @@ -32,16 +32,17 @@ Integration of multiple carriers with Roulier library Base module for integration with Roulier. -`Roulier `_ is a python library which implements carriers API. -This modules contains the core functions for this implementation. +`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** @@ -51,8 +52,14 @@ 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 ===== @@ -60,43 +67,39 @@ 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 =========== @@ -104,7 +107,7 @@ 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 `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -112,18 +115,18 @@ Credits ======= Authors -~~~~~~~ +------- * Akretion Contributors -~~~~~~~~~~~~ +------------ -* Raphaël Reverdy -* David Béal +- Raphaël Reverdy +- David Béal Maintainers -~~~~~~~~~~~ +----------- This module is maintained by the OCA. @@ -143,6 +146,6 @@ Current `maintainer `__: |maintainer-florian-dacosta| -This module is part of the `OCA/delivery-carrier `_ project on GitHub. +This module is part of the `OCA/delivery-carrier `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/delivery_roulier/__manifest__.py b/delivery_roulier/__manifest__.py index b7a4fbfdfa..b9db43e37a 100644 --- a/delivery_roulier/__manifest__.py +++ b/delivery_roulier/__manifest__.py @@ -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"], @@ -20,6 +20,7 @@ "external_dependencies": { "python": [ "roulier", # '>0.2.0' + "odoo_test_helper", ], }, "installable": True, diff --git a/delivery_roulier/decorator.py b/delivery_roulier/decorator.py index f61cc69253..e413e0db5c 100644 --- a/delivery_roulier/decorator.py +++ b/delivery_roulier/decorator.py @@ -34,7 +34,7 @@ def get_delivery_type(cls, *args, **kwargs): return cls[0].carrier_id.delivery_type 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) diff --git a/delivery_roulier/i18n/delivery_roulier.pot b/delivery_roulier/i18n/delivery_roulier.pot index 78d63e9c4c..37158f4d01 100644 --- a/delivery_roulier/i18n/delivery_roulier.pot +++ b/delivery_roulier/i18n/delivery_roulier.pot @@ -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" diff --git a/delivery_roulier/i18n/es.po b/delivery_roulier/i18n/es.po index e9051ac8b4..8a55ca7c72 100644 --- a/delivery_roulier/i18n/es.po +++ b/delivery_roulier/i18n/es.po @@ -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 \n" diff --git a/delivery_roulier/i18n/it.po b/delivery_roulier/i18n/it.po index 4ba6196558..55795effc3 100644 --- a/delivery_roulier/i18n/it.po +++ b/delivery_roulier/i18n/it.po @@ -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 \n" diff --git a/delivery_roulier/models/stock_move_line.py b/delivery_roulier/models/stock_move_line.py index 5dfabde7ea..fd58ac97b9 100644 --- a/delivery_roulier/models/stock_move_line.py +++ b/delivery_roulier/models/stock_move_line.py @@ -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 + + 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 + vals["quant_id"] = quants_by_product.get(move_line.product_id.id).id + return super().write(vals) diff --git a/delivery_roulier/models/stock_picking.py b/delivery_roulier/models/stock_picking.py index 382741c028..42aabd4b97 100644 --- a/delivery_roulier/models/stock_picking.py +++ b/delivery_roulier/models/stock_picking.py @@ -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( @@ -290,3 +290,12 @@ def open_website_url(self): action["domain"] = [("id", "in", packages.ids)] action["context"] = {"picking_id": self.id} return action + + 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 diff --git a/delivery_roulier/models/stock_quant_package.py b/delivery_roulier/models/stock_quant_package.py index c0fe30c958..2917ecc1c0 100644 --- a/delivery_roulier/models/stock_quant_package.py +++ b/delivery_roulier/models/stock_quant_package.py @@ -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 - + 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"), } ) @@ -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 ] diff --git a/delivery_roulier/pyproject.toml b/delivery_roulier/pyproject.toml new file mode 100644 index 0000000000..4231d0cccb --- /dev/null +++ b/delivery_roulier/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/delivery_roulier/readme/CONFIGURE.md b/delivery_roulier/readme/CONFIGURE.md new file mode 100644 index 0000000000..ff4f864fea --- /dev/null +++ b/delivery_roulier/readme/CONFIGURE.md @@ -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. diff --git a/delivery_roulier/readme/CONFIGURE.rst b/delivery_roulier/readme/CONFIGURE.rst deleted file mode 100644 index e7cf93ad3c..0000000000 --- a/delivery_roulier/readme/CONFIGURE.rst +++ /dev/null @@ -1,2 +0,0 @@ -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. diff --git a/delivery_roulier/readme/CONTRIBUTORS.md b/delivery_roulier/readme/CONTRIBUTORS.md new file mode 100644 index 0000000000..74878ac5dd --- /dev/null +++ b/delivery_roulier/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- Raphaël Reverdy \<\> +- David Béal \<\> diff --git a/delivery_roulier/readme/CONTRIBUTORS.rst b/delivery_roulier/readme/CONTRIBUTORS.rst deleted file mode 100644 index 849f52eb53..0000000000 --- a/delivery_roulier/readme/CONTRIBUTORS.rst +++ /dev/null @@ -1,2 +0,0 @@ -* Raphaël Reverdy -* David Béal diff --git a/delivery_roulier/readme/DESCRIPTION.rst b/delivery_roulier/readme/DESCRIPTION.md similarity index 61% rename from delivery_roulier/readme/DESCRIPTION.rst rename to delivery_roulier/readme/DESCRIPTION.md index a6b0e65bc0..bbf7a553d3 100644 --- a/delivery_roulier/readme/DESCRIPTION.rst +++ b/delivery_roulier/readme/DESCRIPTION.md @@ -2,8 +2,9 @@ Integration of multiple carriers with Roulier library Base module for integration with Roulier. -`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 : diff --git a/delivery_roulier/readme/USAGE.md b/delivery_roulier/readme/USAGE.md new file mode 100644 index 0000000000..5028885932 --- /dev/null +++ b/delivery_roulier/readme/USAGE.md @@ -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 +``` diff --git a/delivery_roulier/readme/USAGE.rst b/delivery_roulier/readme/USAGE.rst deleted file mode 100644 index 84d1c0e75a..0000000000 --- a/delivery_roulier/readme/USAGE.rst +++ /dev/null @@ -1,40 +0,0 @@ -Here is some methods you can use for your carrier implementation -allowing to have a consistent code accross different carrier modules: - -.. code-block:: 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: - -.. code-block:: python - - def _mycarrier_get_service(...): - - result = _roulier_get_service(...) - - result["specific_key"] = "blabla" - - return result diff --git a/delivery_roulier/static/description/index.html b/delivery_roulier/static/description/index.html index c94096fc4a..df33aca307 100644 --- a/delivery_roulier/static/description/index.html +++ b/delivery_roulier/static/description/index.html @@ -1,4 +1,3 @@ - @@ -9,10 +8,11 @@ /* :Author: David Goodger (goodger@python.org) -:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $ +:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $ :Copyright: This stylesheet has been placed in the public domain. Default cascading style sheet for the HTML output of Docutils. +Despite the name, some widely supported CSS2 features are used. See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to customize this style sheet. @@ -275,7 +275,7 @@ margin-left: 2em ; margin-right: 2em } -pre.code .ln { color: grey; } /* line numbers */ +pre.code .ln { color: gray; } /* line numbers */ pre.code, code { background-color: #eeeeee } pre.code .comment, code .comment { color: #5C6576 } pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold } @@ -301,7 +301,7 @@ span.pre { white-space: pre } -span.problematic { +span.problematic, pre.problematic { color: red } span.section-subtitle { @@ -369,11 +369,12 @@

Delivery Carrier Roulier

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! source digest: sha256:f1b0fe3fd7a164fd66ce26ba17529c4b1124a199301d27f793e6c756f5a5ec61 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: AGPL-3 OCA/delivery-carrier Translate me on Weblate Try me on Runboat

+

Beta License: AGPL-3 OCA/delivery-carrier Translate me on Weblate Try me on Runboat

Integration of multiple carriers with Roulier library

Base module for integration with Roulier.

-

Roulier is a python library which implements carriers API. -This modules contains the core functions for this implementation.

+

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
  • @@ -398,8 +399,14 @@

    Delivery Carrier Roulier

    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

    @@ -426,10 +433,7 @@

    Usage

    def _mycarrier_convert_address(...): -
    -

    -
    -

    Instead of calling super() you can use:

    +

    Instead of calling super() you can use:

     def _mycarrier_get_service(...):
     
    @@ -445,7 +449,7 @@ 

    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.

    +feedback.

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

    @@ -466,13 +470,15 @@

    Contributors

    Maintainers

    This module is maintained by the OCA.

    -Odoo Community Association + +Odoo Community Association +

    OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

    Current maintainer:

    florian-dacosta

    -

    This module is part of the OCA/delivery-carrier project on GitHub.

    +

    This module is part of the OCA/delivery-carrier project on GitHub.

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

    diff --git a/delivery_roulier/tests/test_delivery_roulier.py b/delivery_roulier/tests/test_delivery_roulier.py index c04aab2c50..72f0be45db 100644 --- a/delivery_roulier/tests/test_delivery_roulier.py +++ b/delivery_roulier/tests/test_delivery_roulier.py @@ -87,12 +87,9 @@ def setUp(self): "location_id": self.order.warehouse_id.lot_stock_id.id, "inventory_quantity": 1, } - )._apply_inventory() + ).action_apply_inventory() self.order.action_confirm() self.picking = self.order.picking_ids - self.env["stock.immediate.transfer"].create( - {"pick_ids": [(6, 0, self.picking.ids)]} - ).process() @classmethod def tearDownClass(cls): diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000000..ae230172ca --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +# generated from manifests external_dependencies +odoo_test_helper +roulier