Skip to content

Commit

Permalink
[MIG] delivery_postlogistics: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bizzappdev authored and RUS committed Feb 7, 2025
1 parent 5293e95 commit df17089
Show file tree
Hide file tree
Showing 26 changed files with 364 additions and 138 deletions.
45 changes: 22 additions & 23 deletions delivery_postlogistics/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,13 @@ See `Log in <https://account.post.ch/selfadmin/?login&lang=en>`__

To configure:

- Go to Inventory -> Configuration -> Delivery -> Shipping Methods
- Create new shipping methods for PostLogistics and set your login
informations in the "PostLogistics" tab
- Go to Inventory -> Configuration -> Delivery -> Delivery Packages to
create the PostLogistics delivery packaging with the relevant Package
Code (see section 8.10 of
https://developer.post.ch/en/digital-commerce-api for available
codes)
- Go to Inventory -> Configuration -> Delivery -> Shipping Methods
- Create new shipping methods for PostLogistics and set your login
informations in the "PostLogistics" tab
- Go to Inventory -> Configuration -> Delivery -> Delivery Packages to
create the PostLogistics delivery packaging with the relevant Package
Code (see section 8.10 of
https://developer.post.ch/en/digital-commerce-api for available codes)

Technical references
--------------------
Expand All @@ -74,11 +73,11 @@ documentation <https://www.post.ch/en/business/a-z-of-subjects/dropping-off-mail
Known issues / Roadmap
======================

- Integration of price webservice :
https://www.post.ch/en/customer-center/all-online-services/preise-berechnen/info
- Not sure if the recursive patch of suds is still needed as there's no
need to use the integration WS anymore. However we still want to
patch open to get meaningful error messages.
- Integration of price webservice :
https://www.post.ch/en/customer-center/all-online-services/preise-berechnen/info
- Not sure if the recursive patch of suds is still needed as there's no
need to use the integration WS anymore. However we still want to patch
open to get meaningful error messages.

Bug Tracker
===========
Expand All @@ -101,31 +100,31 @@ Authors
Contributors
------------

- Yannick Vaucher <[email protected]>
- Yannick Vaucher <[email protected]>

- Guewen Baconnier <[email protected]>
- Guewen Baconnier <[email protected]>

- Akim Juillerat <[email protected]>
- Akim Juillerat <[email protected]>

- Julien Coux <[email protected]>
- Julien Coux <[email protected]>

- Dung Tran <[email protected]>
- Dung Tran <[email protected]>

- Phuc Tran <[email protected]>
- Phuc Tran <[email protected]>

- Jacques-Etienne Baudoux <[email protected]>
- Jacques-Etienne Baudoux <[email protected]>

- `Trobz <https://trobz.com>`__:
- `Trobz <https://trobz.com>`__:

- Jack Le <[email protected]>
- Jack Le <[email protected]>

Other credits
-------------

The development of this module in version 14.0 and its migration from
14.0 to 16.0 has been financially supported by:

- Camptocamp
- Camptocamp

Maintainers
-----------
Expand Down
4 changes: 2 additions & 2 deletions delivery_postlogistics/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
{
"name": "PostLogistics Shipping - “Barcode” web service",
"summary": "Print PostLogistics shipping labels using the Barcode web service",
"version": "16.0.1.1.0",
"version": "18.0.1.0.0",
"author": "Camptocamp,Odoo Community Association (OCA)",
"maintainer": "Camptocamp",
"license": "AGPL-3",
"category": "Delivery",
"complexity": "normal",
"depends": ["delivery", "mail", "base", "stock"],
"depends": ["stock_delivery"],
"website": "https://github.com/OCA/delivery-carrier",
"data": [
"security/ir.model.access.csv",
Expand Down
14 changes: 6 additions & 8 deletions delivery_postlogistics/models/delivery_carrier.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
# Copyright 2013-2016 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import _, api, fields, models
from odoo import api, fields, models
from odoo.exceptions import UserError

from ..postlogistics.web_service import PostlogisticsWebService


class DeliveryCarrier(models.Model):
"""Add service group"""

_inherit = "delivery.carrier"

delivery_type = fields.Selection(
Expand Down Expand Up @@ -114,11 +112,11 @@ def onchange_prod_environment(self):
def postlogistics_get_tracking_link(self, picking):
return (
"https://service.post.ch/EasyTrack/"
"submitParcelData.do?formattedParcelCodes=%s" % picking.carrier_tracking_ref
f"submitParcelData.do?formattedParcelCodes={picking.carrier_tracking_ref}"
)

def postlogistics_cancel_shipment(self, pickings):
raise UserError(_("This feature is under development"))
raise UserError(self.env._("This feature is under development"))

def postlogistics_rate_shipment(self, order):
self.ensure_one()
Expand Down Expand Up @@ -150,15 +148,15 @@ def verify_credentials(self):
"type": "ir.actions.client",
"tag": "display_notification",
"params": {
"title": _("Validated"),
"message": _("The credential is valid."),
"title": self.env._("Validated"),
"message": self.env._("The credential is valid."),
"sticky": False,
},
}
return message

def _compute_can_generate_return(self):
res = super(DeliveryCarrier, self)._compute_can_generate_return()
res = super()._compute_can_generate_return()
for carrier in self:
if carrier.delivery_type == "postlogistics":
carrier.can_generate_return = True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@


class DeliveryCarrierTemplateOption(models.Model):
"""Available options for a carrier (partner)"""

_name = "postlogistics.delivery.carrier.template.option"
_description = "Delivery carrier template option"

Expand Down
2 changes: 0 additions & 2 deletions delivery_postlogistics/models/postlogistics_shipping_label.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@


class PostlogisticsShippingLabel(models.Model):
"""Child class of ir attachment to identify which are labels"""

_name = "postlogistics.shipping.label"
_inherits = {"ir.attachment": "attachment_id"}
_description = "Shipping Label for PostLogistics"
Expand Down
2 changes: 1 addition & 1 deletion delivery_postlogistics/models/stock_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class StockMove(models.Model):
_inherit = "stock.move"

def _get_new_picking_values(self):
vals = super(StockMove, self)._get_new_picking_values()
vals = super()._get_new_picking_values()

order_commitment_date = (
self.sale_line_id and self.sale_line_id.order_id.commitment_date
Expand Down
3 changes: 2 additions & 1 deletion delivery_postlogistics/models/stock_package_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ class PackageType(models.Model):
_inherit = "stock.package.type"

package_carrier_type = fields.Selection(
selection_add=[("postlogistics", "PostLogistics")]
selection_add=[("postlogistics", "PostLogistics")],
ondelete={"postlogistics": "set default"},
)

def _get_packaging_codes(self):
Expand Down
17 changes: 8 additions & 9 deletions delivery_postlogistics/models/stock_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

import lxml.html

from odoo import _, api, exceptions, fields, models
from odoo import api, fields, models
from odoo.exceptions import UserError

from ..postlogistics.web_service import PostlogisticsWebService

Expand Down Expand Up @@ -111,17 +112,17 @@ def postlogistics_cod_amount(self):
if not order:
return 0.0
if len(order) > 1:
raise exceptions.Warning(
_(
raise UserError(
self.env._(
"The cash on delivery amount must be manually specified "
"on the packages when a package contains products "
"from different sales orders."
)
)
# check if the package delivers the whole sales order
if len(order.picking_ids) > 1:
raise exceptions.Warning(
_(
raise UserError(
self.env._(
"The cash on delivery amount must be manually specified "
"on the packages when a sales order is delivered "
"in several delivery orders."
Expand Down Expand Up @@ -235,9 +236,7 @@ def _generate_postlogistics_label(
self._cleanup_error_message(label["errors"])
for label in failed_label_results
)
raise exceptions.UserError(
_("PostLogistics error:") + "\n\n" + error_message
)
raise UserError(self.env._("PostLogistics error:") + "\n\n" + error_message)
return labels

@api.model
Expand All @@ -255,5 +254,5 @@ def generate_postlogistics_shipping_labels(self, package_ids=None):
def action_generate_carrier_label(self):
self.ensure_one()
if not self.carrier_id:
raise exceptions.UserError(_("Please, set a carrier."))
raise UserError(self.env._("Please, set a carrier."))
self.env["delivery.carrier"].postlogistics_send_shipping(self)
11 changes: 6 additions & 5 deletions delivery_postlogistics/models/stock_quant_package.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright 2013-2016 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import _, api, exceptions, fields, models
from odoo import api, fields, models
from odoo.exceptions import UserError


class StockQuantPackage(models.Model):
Expand Down Expand Up @@ -42,8 +43,8 @@ def postlogistics_cod_amount(self):

pickings = self._get_origin_pickings()
if len(pickings) > 1:
raise exceptions.Warning(
_(
raise UserError(
self.env._(
"The cash on delivery amount must be manually specified "
"on the packages when a sales order is delivered "
"in several delivery orders."
Expand All @@ -54,8 +55,8 @@ def postlogistics_cod_amount(self):
if not order:
return 0.0
if len(order) > 1:
raise exceptions.Warning(
_(
raise UserError(
self.env._(
"The cash on delivery amount must be manually specified "
"on the packages when a package contains products "
"from different sales orders."
Expand Down
Loading

0 comments on commit df17089

Please sign in to comment.