Skip to content

Commit

Permalink
[IMP] delivery_ups_oca: pre-commit auto fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Tisho99 committed Feb 20, 2025
1 parent 58aab46 commit ee49105
Show file tree
Hide file tree
Showing 14 changed files with 156 additions and 137 deletions.
100 changes: 53 additions & 47 deletions delivery_ups_oca/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,27 @@ Delivery UPS OCA
: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/14.0/delivery_ups_oca
:target: https://github.com/OCA/delivery-carrier/tree/17.0/delivery_ups_oca
: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-14-0/delivery-carrier-14-0-delivery_ups_oca
:target: https://translation.odoo-community.org/projects/delivery-carrier-17-0/delivery-carrier-17-0-delivery_ups_oca
: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=14.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 adds `UPS <https://ups.com>`_ to the available carriers.
This module adds `UPS <https://ups.com>`__ to the available carriers.

It allows you to register shippings, generate labels, get rates from order, read
shipping states and cancel shipments using UPS webservice, so no need of exchanging
any kind of file.
It allows you to register shippings, generate labels, get rates from
order, read shipping states and cancel shipments using UPS webservice,
so no need of exchanging any kind of file.

When a sales order is created in Odoo and the UPS carrier is assigned, the shipping
price that will be obtained will be the price that the UPS webservice estimates
according to the order information (address and products).
When a sales order is created in Odoo and the UPS carrier is assigned,
the shipping price that will be obtained will be the price that the UPS
webservice estimates according to the order information (address and
products).

**Table of contents**

Expand All @@ -48,79 +49,84 @@ Configuration

To configure this module, you need to:

#. Add a carrier account with delivery type ``ups`` and fill in your credentials (UPS
Client and UPS Client Secret)
#. Configure in Odoo all required fields of the UPS tab with your account data
https://wwwapps.ups.com/ppc/ppc.html (Shipper number, Default Packaging, Package
Dimension Code, Package Weight Code and File Format).
#. If yo have "Tracking state update sync" checked all delivery orders state check will
be done querying UPS services.
#. It is possible to create a UPS carrier for cash on delivery parcels. Select the
``ups`` delivery type and check the "Cash on Delivery" checkbox under the "UPS" tab.
It is required to select the "UPS COD Funds Code" when the "Cash on Delivery" option
is selected.

**NOTE** You need to add an APP from https://developer.ups.com/ for using the
webservice.
1. Add a carrier account with delivery type ``ups`` and fill in your
credentials (UPS Client and UPS Client Secret)
2. Configure in Odoo all required fields of the UPS tab with your
account data https://wwwapps.ups.com/ppc/ppc.html (Shipper number,
Default Packaging, Package Dimension Code, Package Weight Code and
File Format).
3. If yo have "Tracking state update sync" checked all delivery orders
state check will be done querying UPS services.
4. It is possible to create a UPS carrier for cash on delivery parcels.
Select the ``ups`` delivery type and check the "Cash on Delivery"
checkbox under the "UPS" tab. It is required to select the "UPS COD
Funds Code" when the "Cash on Delivery" option is selected.

**NOTE** You need to add an APP from https://developer.ups.com/ for
using the webservice.

Usage
=====

You have to set the created shipping method in the delivery order to ship:
You have to set the created shipping method in the delivery order to
ship:

* When the picking is 'Transferred', a *Create Shipping Label* button appears. Just
click on it, and if all went well, the label will be 'attached'.
* If the shipment creation process fails, a validation error will appear displaying UPS
error.
* When the delivery order is cancelled, it's automatically cancelled too in UPS.
* If you have "Tracking state update sync" checked in the shipping method, a periodical
state check will be done querying UPS services.
- When the picking is 'Transferred', a *Create Shipping Label* button
appears. Just click on it, and if all went well, the label will be
'attached'.
- If the shipment creation process fails, a validation error will
appear displaying UPS error.
- When the delivery order is cancelled, it's automatically cancelled
too in UPS.
- If you have "Tracking state update sync" checked in the shipping
method, a periodical state check will be done querying UPS services.

Known issues / Roadmap
======================

* Support international forms
* Support package service options
- Support international forms
- Support package service options

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_ups_oca%0Aversion:%2014.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_ups_oca%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
~~~~~~~
-------

* Hunki Enterprises BV
* Tecnativa
* ForgeFlow

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

* Holger Brunn <[email protected]> (https://hunki-enterprises.nl)
* `Tecnativa <https://www.tecnativa.com>`_:
- Holger Brunn <[email protected]>
(https://hunki-enterprises.nl)
- `Tecnativa <https://www.tecnativa.com>`__:

* Víctor Martínez
* Pedro M. Baeza
- Víctor Martínez
- Pedro M. Baeza

* `ForgeFlow <https://www.forgeflow.com>`_:
- `ForgeFlow <https://www.forgeflow.com>`__:

* Jordi Ballester
- Jordi Ballester

* `Sygel <https://www.sygel.es>`_:
- `Sygel <https://www.sygel.es>`__:

* Manuel Regidor
- Manuel Regidor

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

This module is maintained by the OCA.

Expand All @@ -132,6 +138,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 <https://github.com/OCA/delivery-carrier/tree/14.0/delivery_ups_oca>`_ project on GitHub.
This module is part of the `OCA/delivery-carrier <https://github.com/OCA/delivery-carrier/tree/17.0/delivery_ups_oca>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
12 changes: 6 additions & 6 deletions delivery_ups_oca/models/ups_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
_logger = logging.getLogger(__name__)


class UpsRequest(object):
class UpsRequest:
def __init__(self, carrier):
self.carrier = carrier
self.default_packaging_id = self.carrier.ups_default_packaging_id
Expand Down Expand Up @@ -90,7 +90,7 @@ def _process_reply(
self._get_new_token()
data = data or {}
headers = {
"Authorization": "Bearer {}".format(self.token),
"Authorization": f"Bearer {self.token}",
}
if headers_extra:
headers = {**headers, **headers_extra}
Expand All @@ -100,7 +100,7 @@ def _process_reply(
self._get_new_token()
status = self._send_request(url, json, data, headers, method)
status = status.json()
ups_last_request = ("URL: {}\nData: {}").format(self.url, data)
ups_last_request = f"URL: {self.url}\nData: {data}"
self.carrier.log_xml(ups_last_request, "ups_last_request")
self.carrier.log_xml(status or "", "ups_last_response")
return status
Expand Down Expand Up @@ -349,7 +349,7 @@ def shipping_label(self, carrier_tracking_ref):

def cancel_shipment(self, picking):
url = "%s/api/shipments/v1/void/cancel" % self.url
url = "{}/{}".format(url, picking.carrier_tracking_ref)
url = f"{url}/{picking.carrier_tracking_ref}"
status = self._process_reply(url=url, method="delete")
self._raise_for_status(status, False)
return True
Expand All @@ -366,8 +366,8 @@ def tracking_state_update(self, picking):
url="%s/api/track/v1/details/%s" % (self.url, picking.carrier_tracking_ref),
method="get",
headers_extra={
"transId": "{}".format(datetime.datetime.now().timestamp()),
"transactionSrc": "{} - Odoo".format(picking.company_id.name),
"transId": f"{datetime.datetime.now().timestamp()}",
"transactionSrc": f"{picking.company_id.name} - Odoo",
},
)
self._raise_for_status(status, False)
Expand Down
3 changes: 3 additions & 0 deletions delivery_ups_oca/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
17 changes: 17 additions & 0 deletions delivery_ups_oca/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
To configure this module, you need to:

1. Add a carrier account with delivery type `ups` and fill in your
credentials (UPS Client and UPS Client Secret)
2. Configure in Odoo all required fields of the UPS tab with your
account data <https://wwwapps.ups.com/ppc/ppc.html> (Shipper number,
Default Packaging, Package Dimension Code, Package Weight Code and
File Format).
3. If yo have "Tracking state update sync" checked all delivery orders
state check will be done querying UPS services.
4. It is possible to create a UPS carrier for cash on delivery parcels.
Select the `ups` delivery type and check the "Cash on Delivery"
checkbox under the "UPS" tab. It is required to select the "UPS COD
Funds Code" when the "Cash on Delivery" option is selected.

**NOTE** You need to add an APP from <https://developer.ups.com/> for
using the webservice.
16 changes: 0 additions & 16 deletions delivery_ups_oca/readme/CONFIGURE.rst

This file was deleted.

9 changes: 9 additions & 0 deletions delivery_ups_oca/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
- Holger Brunn \<<[email protected]>\>
(<https://hunki-enterprises.nl>)
- [Tecnativa](https://www.tecnativa.com):
- Víctor Martínez
- Pedro M. Baeza
- [ForgeFlow](https://www.forgeflow.com):
- Jordi Ballester
- [Sygel](https://www.sygel.es):
- Manuel Regidor
13 changes: 0 additions & 13 deletions delivery_ups_oca/readme/CONTRIBUTORS.rst

This file was deleted.

10 changes: 10 additions & 0 deletions delivery_ups_oca/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
This module adds [UPS](https://ups.com) to the available carriers.

It allows you to register shippings, generate labels, get rates from
order, read shipping states and cancel shipments using UPS webservice,
so no need of exchanging any kind of file.

When a sales order is created in Odoo and the UPS carrier is assigned,
the shipping price that will be obtained will be the price that the UPS
webservice estimates according to the order information (address and
products).
9 changes: 0 additions & 9 deletions delivery_ups_oca/readme/DESCRIPTION.rst

This file was deleted.

2 changes: 2 additions & 0 deletions delivery_ups_oca/readme/ROADMAP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Support international forms
- Support package service options
2 changes: 0 additions & 2 deletions delivery_ups_oca/readme/ROADMAP.rst

This file was deleted.

12 changes: 12 additions & 0 deletions delivery_ups_oca/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
You have to set the created shipping method in the delivery order to
ship:

- When the picking is 'Transferred', a *Create Shipping Label* button
appears. Just click on it, and if all went well, the label will be
'attached'.
- If the shipment creation process fails, a validation error will appear
displaying UPS error.
- When the delivery order is cancelled, it's automatically cancelled too
in UPS.
- If you have "Tracking state update sync" checked in the shipping
method, a periodical state check will be done querying UPS services.
9 changes: 0 additions & 9 deletions delivery_ups_oca/readme/USAGE.rst

This file was deleted.

Loading

0 comments on commit ee49105

Please sign in to comment.