Skip to content

Commit a9d5d72

Browse files
bizzappdevRUS
authored and
RUS
committed
[MIG] delivery_postlogistics: Migration to 18.0
1 parent 5293e95 commit a9d5d72

26 files changed

+355
-138
lines changed

delivery_postlogistics/README.rst

+22-23
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,13 @@ See `Log in <https://account.post.ch/selfadmin/?login&lang=en>`__
5656

5757
To configure:
5858

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

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

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

8382
Bug Tracker
8483
===========
@@ -101,31 +100,31 @@ Authors
101100
Contributors
102101
------------
103102

104-
- Yannick Vaucher <yannick.vaucher@camptocamp.com>
103+
- Yannick Vaucher <yannick.vaucher@camptocamp.com>
105104

106-
- Guewen Baconnier <guewen.baconnier@camptocamp.com>
105+
- Guewen Baconnier <guewen.baconnier@camptocamp.com>
107106

108-
- Akim Juillerat <akim.juillerat@camptocamp.com>
107+
- Akim Juillerat <akim.juillerat@camptocamp.com>
109108

110-
- Julien Coux <julien.coux@camptocamp.com>
109+
- Julien Coux <julien.coux@camptocamp.com>
111110

112-
- Dung Tran <dungtd@trobz.com>
111+
- Dung Tran <dungtd@trobz.com>
113112

114-
- Phuc Tran <phuc@trobz.com>
113+
- Phuc Tran <phuc@trobz.com>
115114

116-
- Jacques-Etienne Baudoux <je@bcim.be>
115+
- Jacques-Etienne Baudoux <je@bcim.be>
117116

118-
- `Trobz <https://trobz.com>`__:
117+
- `Trobz <https://trobz.com>`__:
119118

120-
- Jack Le <anlh@trobz.com>
119+
- Jack Le <anlh@trobz.com>
121120

122121
Other credits
123122
-------------
124123

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

128-
- Camptocamp
127+
- Camptocamp
129128

130129
Maintainers
131130
-----------

delivery_postlogistics/__manifest__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
{
44
"name": "PostLogistics Shipping - “Barcode” web service",
55
"summary": "Print PostLogistics shipping labels using the Barcode web service",
6-
"version": "16.0.1.1.0",
6+
"version": "18.0.1.0.0",
77
"author": "Camptocamp,Odoo Community Association (OCA)",
88
"maintainer": "Camptocamp",
99
"license": "AGPL-3",
1010
"category": "Delivery",
1111
"complexity": "normal",
12-
"depends": ["delivery", "mail", "base", "stock"],
12+
"depends": ["stock_delivery"],
1313
"website": "https://github.com/OCA/delivery-carrier",
1414
"data": [
1515
"security/ir.model.access.csv",

delivery_postlogistics/models/delivery_carrier.py

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
# Copyright 2013-2016 Camptocamp SA
22
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
33

4-
from odoo import _, api, fields, models
4+
from odoo import api, fields, models
55
from odoo.exceptions import UserError
66

77
from ..postlogistics.web_service import PostlogisticsWebService
88

99

1010
class DeliveryCarrier(models.Model):
11-
"""Add service group"""
12-
1311
_inherit = "delivery.carrier"
1412

1513
delivery_type = fields.Selection(
@@ -114,11 +112,11 @@ def onchange_prod_environment(self):
114112
def postlogistics_get_tracking_link(self, picking):
115113
return (
116114
"https://service.post.ch/EasyTrack/"
117-
"submitParcelData.do?formattedParcelCodes=%s" % picking.carrier_tracking_ref
115+
f"submitParcelData.do?formattedParcelCodes={picking.carrier_tracking_ref}"
118116
)
119117

120118
def postlogistics_cancel_shipment(self, pickings):
121-
raise UserError(_("This feature is under development"))
119+
raise UserError(self.env._("This feature is under development"))
122120

123121
def postlogistics_rate_shipment(self, order):
124122
self.ensure_one()
@@ -150,15 +148,15 @@ def verify_credentials(self):
150148
"type": "ir.actions.client",
151149
"tag": "display_notification",
152150
"params": {
153-
"title": _("Validated"),
154-
"message": _("The credential is valid."),
151+
"title": self.env._("Validated"),
152+
"message": self.env._("The credential is valid."),
155153
"sticky": False,
156154
},
157155
}
158156
return message
159157

160158
def _compute_can_generate_return(self):
161-
res = super(DeliveryCarrier, self)._compute_can_generate_return()
159+
res = super()._compute_can_generate_return()
162160
for carrier in self:
163161
if carrier.delivery_type == "postlogistics":
164162
carrier.can_generate_return = True

delivery_postlogistics/models/postlogistics_carrier_template_options.py

-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515

1616

1717
class DeliveryCarrierTemplateOption(models.Model):
18-
"""Available options for a carrier (partner)"""
19-
2018
_name = "postlogistics.delivery.carrier.template.option"
2119
_description = "Delivery carrier template option"
2220

delivery_postlogistics/models/postlogistics_shipping_label.py

-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55

66

77
class PostlogisticsShippingLabel(models.Model):
8-
"""Child class of ir attachment to identify which are labels"""
9-
108
_name = "postlogistics.shipping.label"
119
_inherits = {"ir.attachment": "attachment_id"}
1210
_description = "Shipping Label for PostLogistics"

delivery_postlogistics/models/stock_move.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class StockMove(models.Model):
88
_inherit = "stock.move"
99

1010
def _get_new_picking_values(self):
11-
vals = super(StockMove, self)._get_new_picking_values()
11+
vals = super()._get_new_picking_values()
1212

1313
order_commitment_date = (
1414
self.sale_line_id and self.sale_line_id.order_id.commitment_date

delivery_postlogistics/models/stock_package_type.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ class PackageType(models.Model):
88
_inherit = "stock.package.type"
99

1010
package_carrier_type = fields.Selection(
11-
selection_add=[("postlogistics", "PostLogistics")]
11+
selection_add=[("postlogistics", "PostLogistics")],
12+
ondelete={"postlogistics": "set default"},
1213
)
1314

1415
def _get_packaging_codes(self):

delivery_postlogistics/models/stock_picking.py

+8-9
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66
import lxml.html
77

8-
from odoo import _, api, exceptions, fields, models
8+
from odoo import api, fields, models
9+
from odoo.exceptions import UserError
910

1011
from ..postlogistics.web_service import PostlogisticsWebService
1112

@@ -111,17 +112,17 @@ def postlogistics_cod_amount(self):
111112
if not order:
112113
return 0.0
113114
if len(order) > 1:
114-
raise exceptions.Warning(
115-
_(
115+
raise UserError(
116+
self.env._(
116117
"The cash on delivery amount must be manually specified "
117118
"on the packages when a package contains products "
118119
"from different sales orders."
119120
)
120121
)
121122
# check if the package delivers the whole sales order
122123
if len(order.picking_ids) > 1:
123-
raise exceptions.Warning(
124-
_(
124+
raise UserError(
125+
self.env._(
125126
"The cash on delivery amount must be manually specified "
126127
"on the packages when a sales order is delivered "
127128
"in several delivery orders."
@@ -235,9 +236,7 @@ def _generate_postlogistics_label(
235236
self._cleanup_error_message(label["errors"])
236237
for label in failed_label_results
237238
)
238-
raise exceptions.UserError(
239-
_("PostLogistics error:") + "\n\n" + error_message
240-
)
239+
raise UserError(self.env._("PostLogistics error:") + "\n\n" + error_message)
241240
return labels
242241

243242
@api.model
@@ -255,5 +254,5 @@ def generate_postlogistics_shipping_labels(self, package_ids=None):
255254
def action_generate_carrier_label(self):
256255
self.ensure_one()
257256
if not self.carrier_id:
258-
raise exceptions.UserError(_("Please, set a carrier."))
257+
raise UserError(self.env._("Please, set a carrier."))
259258
self.env["delivery.carrier"].postlogistics_send_shipping(self)

delivery_postlogistics/models/stock_quant_package.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Copyright 2013-2016 Camptocamp SA
22
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3-
from odoo import _, api, exceptions, fields, models
3+
from odoo import api, fields, models
4+
from odoo.exceptions import UserError
45

56

67
class StockQuantPackage(models.Model):
@@ -42,8 +43,8 @@ def postlogistics_cod_amount(self):
4243

4344
pickings = self._get_origin_pickings()
4445
if len(pickings) > 1:
45-
raise exceptions.Warning(
46-
_(
46+
raise UserError(
47+
self.env._(
4748
"The cash on delivery amount must be manually specified "
4849
"on the packages when a sales order is delivered "
4950
"in several delivery orders."
@@ -54,8 +55,8 @@ def postlogistics_cod_amount(self):
5455
if not order:
5556
return 0.0
5657
if len(order) > 1:
57-
raise exceptions.Warning(
58-
_(
58+
raise UserError(
59+
self.env._(
5960
"The cash on delivery amount must be manually specified "
6061
"on the packages when a package contains products "
6162
"from different sales orders."

0 commit comments

Comments
 (0)