From c68e2b0594915d3b4c1353ff078380d85ccf0dcd Mon Sep 17 00:00:00 2001 From: Sandeep Date: Wed, 11 Sep 2024 16:04:57 +0530 Subject: [PATCH] [IMP] delivery_purchase: pre-commit auto fixes --- delivery_purchase/README.rst | 63 ++++++++++--------- delivery_purchase/__manifest__.py | 4 +- delivery_purchase/models/delivery_carrier.py | 2 +- delivery_purchase/models/stock_picking.py | 17 +++-- delivery_purchase/pyproject.toml | 3 + delivery_purchase/readme/CONTRIBUTORS.md | 8 +++ delivery_purchase/readme/CONTRIBUTORS.rst | 6 -- .../{DESCRIPTION.rst => DESCRIPTION.md} | 8 +-- delivery_purchase/readme/USAGE.md | 19 ++++++ delivery_purchase/readme/USAGE.rst | 17 ----- .../static/description/index.html | 44 ++++++------- .../tests/test_delivery_purchase.py | 6 +- .../views/purchase_order_view.xml | 4 +- .../views/stock_picking_view.xml | 7 ++- 14 files changed, 115 insertions(+), 93 deletions(-) create mode 100644 delivery_purchase/pyproject.toml create mode 100644 delivery_purchase/readme/CONTRIBUTORS.md delete mode 100644 delivery_purchase/readme/CONTRIBUTORS.rst rename delivery_purchase/readme/{DESCRIPTION.rst => DESCRIPTION.md} (56%) create mode 100644 delivery_purchase/readme/USAGE.md delete mode 100644 delivery_purchase/readme/USAGE.rst diff --git a/delivery_purchase/README.rst b/delivery_purchase/README.rst index d7fc4cb711..ac3e469491 100644 --- a/delivery_purchase/README.rst +++ b/delivery_purchase/README.rst @@ -17,22 +17,22 @@ Delivery costs in purchases :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_purchase + :target: https://github.com/OCA/delivery-carrier/tree/17.0/delivery_purchase :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_purchase + :target: https://translation.odoo-community.org/projects/delivery-carrier-17-0/delivery-carrier-17-0-delivery_purchase :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| -This module allows to use delivery methods defined in *delivery* module to -calculate purchase delivery costs. +This module allows to use delivery methods defined in *delivery* module +to calculate purchase delivery costs. -It reverses destinations in delivery pricelists to use them as sources when -applying the delivery method to purchases. +It reverses destinations in delivery pricelists to use them as sources +when applying the delivery method to purchases. **Table of contents** @@ -44,21 +44,22 @@ Usage To use this module, you need to: -#. Go to *Purchase > Orders > Purchase Orders* and create a new Purchase Order. -#. Select a carrier in the field 'Delivery Method', fill out the rest - of the form, be sure you added lines with storable products - and save the form. -#. Confirm the purchase order. -#. Go to the linked 'Receipt' by clicking on 'Receipt' smart-button and +1. Go to *Purchase > Orders > Purchase Orders* and create a new Purchase + Order. +2. Select a carrier in the field 'Delivery Method', fill out the rest of + the form, be sure you added lines with storable products and save the + form. +3. Confirm the purchase order. +4. Go to the linked 'Receipt' by clicking on 'Receipt' smart-button and you will see, under 'Additional info' tab, the same carrier selected in the purchase order. -#. If necessary, you can change the carrier in the 'Receipt'. When - it is validated, the 'shipping cost' of the receipt will be - calculated according to that new selected Carrier. -#. It is possible to change the shipping cost in picking. -#. The shipping cost will appear in an internal note created +5. If necessary, you can change the carrier in the 'Receipt'. When it is + validated, the 'shipping cost' of the receipt will be calculated + according to that new selected Carrier. +6. It is possible to change the shipping cost in picking. +7. The shipping cost will appear in an internal note created automatically when the 'Receipt' is validated. -#. A purchase order line will have been created for the cost of picking. +8. A purchase order line will have been created for the cost of picking. Bug Tracker =========== @@ -66,7 +67,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. @@ -74,22 +75,26 @@ Credits ======= Authors -~~~~~~~ +------- * Tecnativa Contributors -~~~~~~~~~~~~ +------------ -* `Tecnativa `_: +- `Tecnativa `__: - * Ernesto Tejeda - * Pedro M. Baeza - * Vicent Cubells - * Carolina Fernandez + - Ernesto Tejeda + - Pedro M. Baeza + - Vicent Cubells + - Carolina Fernandez + +- `Sodexis `__: + + - Sandeep J Maintainers -~~~~~~~~~~~ +----------- This module is maintained by the OCA. @@ -101,6 +106,6 @@ 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. -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_purchase/__manifest__.py b/delivery_purchase/__manifest__.py index 52b36bd946..65d4591f5f 100644 --- a/delivery_purchase/__manifest__.py +++ b/delivery_purchase/__manifest__.py @@ -6,12 +6,12 @@ { "name": "Delivery costs in purchases", - "version": "16.0.1.1.0", + "version": "17.0.1.1.0", "development_status": "Production/Stable", "category": "Operations/Purchase", "website": "https://github.com/OCA/delivery-carrier", "author": "Tecnativa, Odoo Community Association (OCA)", "license": "AGPL-3", - "depends": ["purchase", "delivery"], + "depends": ["purchase", "stock_delivery"], "data": ["views/purchase_order_view.xml", "views/stock_picking_view.xml"], } diff --git a/delivery_purchase/models/delivery_carrier.py b/delivery_purchase/models/delivery_carrier.py index 55ae7981f4..911f9ed74c 100644 --- a/delivery_purchase/models/delivery_carrier.py +++ b/delivery_purchase/models/delivery_carrier.py @@ -144,7 +144,7 @@ def _purchase_get_price_available(self, order): order = order.sudo() weight = volume = quantity = 0 for line in order.order_line.filtered( - lambda l: l.state != "cancel" and bool(l.product_id) + lambda ln: ln.state != "cancel" and bool(ln.product_id) ): qty = line.product_uom._compute_quantity( line.product_uom_qty, line.product_id.uom_id diff --git a/delivery_purchase/models/stock_picking.py b/delivery_purchase/models/stock_picking.py index 0345f4137b..a1a578f729 100644 --- a/delivery_purchase/models/stock_picking.py +++ b/delivery_purchase/models/stock_picking.py @@ -1,5 +1,7 @@ # Copyright 2021 Tecnativa - Ernesto Tejeda # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from markupsafe import Markup + from odoo import _, models @@ -29,13 +31,18 @@ def purchase_send_to_shipper(self): if res["tracking_number"]: self.carrier_tracking_ref = res["tracking_number"] order_currency = self.purchase_id.currency_id or self.company_id.currency_id - msg = _( - "Shipment sent to carrier %(carrier_name)s for shipping with tracking " - "number %(tracking_ref)s
Cost: %(carrier_price)s %(currency_name)s" - ) % ( - { + msg = ( + _( + "Shipment sent to carrier %(carrier_name)s for shipping with \ + tracking number %(tracking_ref)s" + ) + % { "carrier_name": self.carrier_id.name, "tracking_ref": self.carrier_tracking_ref, + } + + Markup("
") + + _("Cost: %(carrier_price)s %(currency_name)s") + % { "carrier_price": "%.2f" % self.carrier_price, "currency_name": order_currency.name, } diff --git a/delivery_purchase/pyproject.toml b/delivery_purchase/pyproject.toml new file mode 100644 index 0000000000..4231d0cccb --- /dev/null +++ b/delivery_purchase/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/delivery_purchase/readme/CONTRIBUTORS.md b/delivery_purchase/readme/CONTRIBUTORS.md new file mode 100644 index 0000000000..5d485351ce --- /dev/null +++ b/delivery_purchase/readme/CONTRIBUTORS.md @@ -0,0 +1,8 @@ +- [Tecnativa](https://www.tecnativa.com): + - Ernesto Tejeda + - Pedro M. Baeza + - Vicent Cubells + - Carolina Fernandez + +- [Sodexis](https://www.sodexis.com): + - Sandeep J diff --git a/delivery_purchase/readme/CONTRIBUTORS.rst b/delivery_purchase/readme/CONTRIBUTORS.rst deleted file mode 100644 index 5abfa83e6d..0000000000 --- a/delivery_purchase/readme/CONTRIBUTORS.rst +++ /dev/null @@ -1,6 +0,0 @@ -* `Tecnativa `_: - - * Ernesto Tejeda - * Pedro M. Baeza - * Vicent Cubells - * Carolina Fernandez diff --git a/delivery_purchase/readme/DESCRIPTION.rst b/delivery_purchase/readme/DESCRIPTION.md similarity index 56% rename from delivery_purchase/readme/DESCRIPTION.rst rename to delivery_purchase/readme/DESCRIPTION.md index 5ab3e3d2ae..b09a4806bd 100644 --- a/delivery_purchase/readme/DESCRIPTION.rst +++ b/delivery_purchase/readme/DESCRIPTION.md @@ -1,5 +1,5 @@ -This module allows to use delivery methods defined in *delivery* module to -calculate purchase delivery costs. +This module allows to use delivery methods defined in *delivery* module +to calculate purchase delivery costs. -It reverses destinations in delivery pricelists to use them as sources when -applying the delivery method to purchases. +It reverses destinations in delivery pricelists to use them as sources +when applying the delivery method to purchases. diff --git a/delivery_purchase/readme/USAGE.md b/delivery_purchase/readme/USAGE.md new file mode 100644 index 0000000000..acc5127049 --- /dev/null +++ b/delivery_purchase/readme/USAGE.md @@ -0,0 +1,19 @@ +To use this module, you need to: + +1. Go to *Purchase \> Orders \> Purchase Orders* and create a new + Purchase Order. +2. Select a carrier in the field 'Delivery Method', fill out the rest + of the form, be sure you added lines with storable products and save + the form. +3. Confirm the purchase order. +4. Go to the linked 'Receipt' by clicking on 'Receipt' smart-button and + you will see, under 'Additional info' tab, the same carrier selected + in the purchase order. +5. If necessary, you can change the carrier in the 'Receipt'. When it + is validated, the 'shipping cost' of the receipt will be calculated + according to that new selected Carrier. +6. It is possible to change the shipping cost in picking. +7. The shipping cost will appear in an internal note created + automatically when the 'Receipt' is validated. +8. A purchase order line will have been created for the cost of + picking. diff --git a/delivery_purchase/readme/USAGE.rst b/delivery_purchase/readme/USAGE.rst deleted file mode 100644 index a56a676411..0000000000 --- a/delivery_purchase/readme/USAGE.rst +++ /dev/null @@ -1,17 +0,0 @@ -To use this module, you need to: - -#. Go to *Purchase > Orders > Purchase Orders* and create a new Purchase Order. -#. Select a carrier in the field 'Delivery Method', fill out the rest - of the form, be sure you added lines with storable products - and save the form. -#. Confirm the purchase order. -#. Go to the linked 'Receipt' by clicking on 'Receipt' smart-button and - you will see, under 'Additional info' tab, the same carrier selected - in the purchase order. -#. If necessary, you can change the carrier in the 'Receipt'. When - it is validated, the 'shipping cost' of the receipt will be - calculated according to that new selected Carrier. -#. It is possible to change the shipping cost in picking. -#. The shipping cost will appear in an internal note created - automatically when the 'Receipt' is validated. -#. A purchase order line will have been created for the cost of picking. diff --git a/delivery_purchase/static/description/index.html b/delivery_purchase/static/description/index.html index 20df721a0d..41fa33e4d7 100644 --- a/delivery_purchase/static/description/index.html +++ b/delivery_purchase/static/description/index.html @@ -8,11 +8,10 @@ /* :Author: David Goodger (goodger@python.org) -:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $ +:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z 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 +274,7 @@ margin-left: 2em ; margin-right: 2em } -pre.code .ln { color: gray; } /* line numbers */ +pre.code .ln { color: grey; } /* 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 +300,7 @@ span.pre { white-space: pre } -span.problematic, pre.problematic { +span.problematic { color: red } span.section-subtitle { @@ -369,11 +368,11 @@

Delivery costs in purchases

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! source digest: sha256:db6d440113ff4fb7edc52ddbdffc7e177d3ff2925d96f349f39754bd0e00617f !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

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

-

This module allows to use delivery methods defined in delivery module to -calculate purchase delivery costs.

-

It reverses destinations in delivery pricelists to use them as sources when -applying the delivery method to purchases.

+

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

+

This module allows to use delivery methods defined in delivery module +to calculate purchase delivery costs.

+

It reverses destinations in delivery pricelists to use them as sources +when applying the delivery method to purchases.

Table of contents

    @@ -391,17 +390,18 @@

    Delivery costs in purchases

    Usage

    To use this module, you need to:

      -
    1. Go to Purchase > Orders > Purchase Orders and create a new Purchase Order.
    2. -
    3. Select a carrier in the field ‘Delivery Method’, fill out the rest -of the form, be sure you added lines with storable products -and save the form.
    4. +
    5. Go to Purchase > Orders > Purchase Orders and create a new Purchase +Order.
    6. +
    7. Select a carrier in the field ‘Delivery Method’, fill out the rest of +the form, be sure you added lines with storable products and save the +form.
    8. Confirm the purchase order.
    9. Go to the linked ‘Receipt’ by clicking on ‘Receipt’ smart-button and you will see, under ‘Additional info’ tab, the same carrier selected in the purchase order.
    10. -
    11. If necessary, you can change the carrier in the ‘Receipt’. When -it is validated, the ‘shipping cost’ of the receipt will be -calculated according to that new selected Carrier.
    12. +
    13. If necessary, you can change the carrier in the ‘Receipt’. When it is +validated, the ‘shipping cost’ of the receipt will be calculated +according to that new selected Carrier.
    14. It is possible to change the shipping cost in picking.
    15. The shipping cost will appear in an internal note created automatically when the ‘Receipt’ is validated.
    16. @@ -413,7 +413,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.

@@ -434,18 +434,20 @@

Contributors

  • Carolina Fernandez
  • +
  • Sodexis:
      +
    • Sandeep J
    • +
    +
  • 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.

    -

    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_purchase/tests/test_delivery_purchase.py b/delivery_purchase/tests/test_delivery_purchase.py index c496a485f0..ca61368285 100644 --- a/delivery_purchase/tests/test_delivery_purchase.py +++ b/delivery_purchase/tests/test_delivery_purchase.py @@ -65,9 +65,7 @@ def setUpClass(cls): cls.purchase_line = cls.purchase.order_line def _action_picking_validate(self, picking): - res = picking.button_validate() - model = self.env[res["res_model"]].with_context(**res["context"]) - model.create({}).process() + picking.button_validate() class TestDeliveryPurchase(TestDeliveryPurchaseBase): @@ -129,7 +127,7 @@ def test_picking_carrier_multi(self): picking = self.purchase.picking_ids picking.carrier_id = self.carrier_fixed for move in picking.move_ids_without_package: - move.quantity_done = 1 + move.quantity = 1 res = picking.button_validate() model = self.env[res["res_model"]].with_context(**res["context"]) model.create({}).process_cancel_backorder() diff --git a/delivery_purchase/views/purchase_order_view.xml b/delivery_purchase/views/purchase_order_view.xml index 3fd0a91e74..37fb11e202 100644 --- a/delivery_purchase/views/purchase_order_view.xml +++ b/delivery_purchase/views/purchase_order_view.xml @@ -14,7 +14,7 @@ name="delivery_price" widget='monetary' options="{'currency_field': 'currency_id'}" - attrs="{'invisible': [('carrier_id', '=', False)]}" + invisible="not carrier_id" /> @@ -24,7 +24,7 @@ > diff --git a/delivery_purchase/views/stock_picking_view.xml b/delivery_purchase/views/stock_picking_view.xml index 79b6e7f969..e8a736b852 100644 --- a/delivery_purchase/views/stock_picking_view.xml +++ b/delivery_purchase/views/stock_picking_view.xml @@ -3,14 +3,17 @@ delivery.stock.picking_withcarrier.form.view stock.picking - +