Skip to content

Commit f0595ac

Browse files
committed
[MIG] delivery_postlogistics: Migration to 14.0
The cassette `tests/fixtures/cassettes/test_store_label.yaml` should be updated as the label was failed to decode in both 13.0 and 14.0. * https://github.com/odoo/odoo/blob/13.0/odoo/addons/base/models/ir_attachment.py#L212 * https://github.com/odoo/odoo/blob/14.0/odoo/addons/base/models/ir_attachment.py#L554 We can remove the method _selection_file_type with below reasons. * It is used in base_delivery_carrier_label but was removed on Sep 5, 2019 https://github.com/OCA/delivery-carrier/blame/12.0/base_delivery_carrier_label/models/shipping_label.py#L15 * PR migration to 13.0 of base_delivery_carrier_label was merged on Oct 22, 2020 https://github.com/OCA/delivery-carrier/pull/251/files * Dependency on base_delivery_carrier_label was removed in migration to 14.0 on Apr 14 2021 OCA@4ba2b56#diff-f16078e35000c05a9b63f5e7e04b6f5fd50eadae8b14a45aa9c1eb078031060cL12 OCA@4ba2b56#diff-08c11b571d9c0b0c509c3922c77f407ef4c429473fda9bc2d4d542520e7a4e3fR12
1 parent 82703b2 commit f0595ac

20 files changed

+186
-89
lines changed

delivery_postlogistics/README.rst

+6-6
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ PostLogistics Shipping - “Barcode” web service
1414
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
1515
:alt: License: AGPL-3
1616
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fdelivery--carrier-lightgray.png?logo=github
17-
:target: https://github.com/OCA/delivery-carrier/tree/13.0/delivery_postlogistics
17+
:target: https://github.com/OCA/delivery-carrier/tree/14.0/delivery_postlogistics
1818
:alt: OCA/delivery-carrier
1919
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
20-
:target: https://translation.odoo-community.org/projects/delivery-carrier-13-0/delivery-carrier-13-0-delivery_postlogistics
20+
:target: https://translation.odoo-community.org/projects/delivery-carrier-14-0/delivery-carrier-14-0-delivery_postlogistics
2121
:alt: Translate me on Weblate
2222
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
23-
:target: https://runbot.odoo-community.org/runbot/99/13.0
23+
:target: https://runbot.odoo-community.org/runbot/99/14.0
2424
:alt: Try me on Runbot
2525

2626
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -83,7 +83,7 @@ Bug Tracker
8383
Bugs are tracked on `GitHub Issues <https://github.com/OCA/delivery-carrier/issues>`_.
8484
In case of trouble, please check there if your issue has already been reported.
8585
If you spotted it first, help us smashing it by providing a detailed and welcomed
86-
`feedback <https://github.com/OCA/delivery-carrier/issues/new?body=module:%20delivery_postlogistics%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
86+
`feedback <https://github.com/OCA/delivery-carrier/issues/new?body=module:%20delivery_postlogistics%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
8787

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

@@ -109,7 +109,7 @@ Contributors
109109
Other credits
110110
~~~~~~~~~~~~~
111111

112-
The development of this module has been financially supported by:
112+
The development of this module in version 13.0 and its migration from 13.0 to 14.0 has been financially supported by:
113113

114114
* Camptocamp
115115

@@ -126,6 +126,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
126126
mission is to support the collaborative development of Odoo features and
127127
promote its widespread use.
128128

129-
This module is part of the `OCA/delivery-carrier <https://github.com/OCA/delivery-carrier/tree/13.0/delivery_postlogistics>`_ project on GitHub.
129+
This module is part of the `OCA/delivery-carrier <https://github.com/OCA/delivery-carrier/tree/14.0/delivery_postlogistics>`_ project on GitHub.
130130

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

delivery_postlogistics/__manifest__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{
44
"name": "PostLogistics Shipping - “Barcode” web service",
55
"summary": "Print PostLogistics shipping labels using the Barcode web service",
6-
"version": "13.0.1.2.0",
6+
"version": "14.0.1.0.0",
77
"author": "Camptocamp,Odoo Community Association (OCA)",
88
"maintainer": "Camptocamp",
99
"license": "AGPL-3",
@@ -12,6 +12,7 @@
1212
"depends": ["delivery", "mail", "base"],
1313
"website": "https://github.com/OCA/delivery-carrier",
1414
"data": [
15+
"security/ir.model.access.csv",
1516
"data/partner.xml",
1617
"data/product.xml",
1718
"data/delivery.xml",
@@ -21,7 +22,6 @@
2122
"views/postlogistics_license.xml",
2223
"views/res_partner_view.xml",
2324
"views/stock.xml",
24-
"security/ir.model.access.csv",
2525
],
2626
"installable": True,
2727
"auto_install": False,

delivery_postlogistics/i18n/delivery_postlogistics.pot

+32-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
#
55
msgid ""
66
msgstr ""
7-
"Project-Id-Version: Odoo Server 13.0\n"
7+
"Project-Id-Version: Odoo Server 14.0\n"
88
"Report-Msgid-Bugs-To: \n"
9+
"POT-Creation-Date: 2021-06-21 02:01+0000\n"
10+
"PO-Revision-Date: 2021-06-21 02:01+0000\n"
911
"Last-Translator: \n"
1012
"Language-Team: \n"
1113
"MIME-Version: 1.0\n"
@@ -186,9 +188,15 @@ msgid "Disabled"
186188
msgstr ""
187189

188190
#. module: delivery_postlogistics
191+
#: model:ir.model.fields,field_description:delivery_postlogistics.field_delivery_carrier__display_name
189192
#: model:ir.model.fields,field_description:delivery_postlogistics.field_postlogistics_delivery_carrier_template_option__display_name
190193
#: model:ir.model.fields,field_description:delivery_postlogistics.field_postlogistics_license__display_name
191194
#: model:ir.model.fields,field_description:delivery_postlogistics.field_postlogistics_shipping_label__display_name
195+
#: model:ir.model.fields,field_description:delivery_postlogistics.field_product_packaging__display_name
196+
#: model:ir.model.fields,field_description:delivery_postlogistics.field_res_partner__display_name
197+
#: model:ir.model.fields,field_description:delivery_postlogistics.field_stock_move__display_name
198+
#: model:ir.model.fields,field_description:delivery_postlogistics.field_stock_picking__display_name
199+
#: model:ir.model.fields,field_description:delivery_postlogistics.field_stock_quant_package__display_name
192200
msgid "Display Name"
193201
msgstr ""
194202

@@ -226,7 +234,12 @@ msgstr ""
226234

227235
#. module: delivery_postlogistics
228236
#: model:ir.model.fields,field_description:delivery_postlogistics.field_postlogistics_shipping_label__datas
229-
msgid "File Content"
237+
msgid "File Content (base64)"
238+
msgstr ""
239+
240+
#. module: delivery_postlogistics
241+
#: model:ir.model.fields,field_description:delivery_postlogistics.field_postlogistics_shipping_label__raw
242+
msgid "File Content (raw)"
230243
msgstr ""
231244

232245
#. module: delivery_postlogistics
@@ -293,9 +306,15 @@ msgid ""
293306
msgstr ""
294307

295308
#. module: delivery_postlogistics
309+
#: model:ir.model.fields,field_description:delivery_postlogistics.field_delivery_carrier__id
296310
#: model:ir.model.fields,field_description:delivery_postlogistics.field_postlogistics_delivery_carrier_template_option__id
297311
#: model:ir.model.fields,field_description:delivery_postlogistics.field_postlogistics_license__id
298312
#: model:ir.model.fields,field_description:delivery_postlogistics.field_postlogistics_shipping_label__id
313+
#: model:ir.model.fields,field_description:delivery_postlogistics.field_product_packaging__id
314+
#: model:ir.model.fields,field_description:delivery_postlogistics.field_res_partner__id
315+
#: model:ir.model.fields,field_description:delivery_postlogistics.field_stock_move__id
316+
#: model:ir.model.fields,field_description:delivery_postlogistics.field_stock_picking__id
317+
#: model:ir.model.fields,field_description:delivery_postlogistics.field_stock_quant_package__id
299318
msgid "ID"
300319
msgstr ""
301320

@@ -347,9 +366,15 @@ msgid "Label layout"
347366
msgstr ""
348367

349368
#. module: delivery_postlogistics
369+
#: model:ir.model.fields,field_description:delivery_postlogistics.field_delivery_carrier____last_update
350370
#: model:ir.model.fields,field_description:delivery_postlogistics.field_postlogistics_delivery_carrier_template_option____last_update
351371
#: model:ir.model.fields,field_description:delivery_postlogistics.field_postlogistics_license____last_update
352372
#: model:ir.model.fields,field_description:delivery_postlogistics.field_postlogistics_shipping_label____last_update
373+
#: model:ir.model.fields,field_description:delivery_postlogistics.field_product_packaging____last_update
374+
#: model:ir.model.fields,field_description:delivery_postlogistics.field_res_partner____last_update
375+
#: model:ir.model.fields,field_description:delivery_postlogistics.field_stock_move____last_update
376+
#: model:ir.model.fields,field_description:delivery_postlogistics.field_stock_picking____last_update
377+
#: model:ir.model.fields,field_description:delivery_postlogistics.field_stock_quant_package____last_update
353378
msgid "Last Modified on"
354379
msgstr ""
355380

@@ -441,6 +466,11 @@ msgid ""
441466
"We recommend using a black and white logo for printing in the ZPL2 format."
442467
msgstr ""
443468

469+
#. module: delivery_postlogistics
470+
#: model:ir.model.fields,field_description:delivery_postlogistics.field_postlogistics_shipping_label__original_id
471+
msgid "Original (unoptimized, unresized) attachment"
472+
msgstr ""
473+
444474
#. module: delivery_postlogistics
445475
#: model:ir.model.fields.selection,name:delivery_postlogistics.selection__postlogistics_delivery_carrier_template_option__postlogistics_type__output_format
446476
msgid "Output Format"

delivery_postlogistics/models/delivery_carrier.py

+27-3
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,26 @@
44
from odoo import _, api, fields, models
55
from odoo.exceptions import UserError
66

7+
from ..postlogistics.web_service import PostlogisticsWebService
8+
79

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

1113
_inherit = "delivery.carrier"
1214

13-
delivery_type = fields.Selection(selection_add=[("postlogistics", "PostLogistics")])
15+
delivery_type = fields.Selection(
16+
selection_add=[("postlogistics", "PostLogistics")],
17+
ondelete={"postlogistics": "set default"},
18+
)
1419
postlogistics_default_packaging_id = fields.Many2one(
1520
"product.packaging", domain=[("package_carrier_type", "=", "postlogistics")]
1621
)
1722

1823
postlogistics_endpoint_url = fields.Char(
19-
string="Endpoint URL", default="https://wedecint.post.ch/", required=True,
24+
string="Endpoint URL",
25+
default="https://wedecint.post.ch/",
26+
required=True,
2027
)
2128
postlogistics_client_id = fields.Char(
2229
string="Client ID", groups="base.group_system"
@@ -84,7 +91,8 @@ class DeliveryCarrier(models.Model):
8491
)
8592

8693
postlogistics_license_id = fields.Many2one(
87-
comodel_name="postlogistics.license", string="Franking License",
94+
comodel_name="postlogistics.license",
95+
string="Franking License",
8896
)
8997
zpl_patch_string = fields.Char(
9098
string="ZPL Patch String", default="^XA^CW0,E:TT0003M_.TTF^XZ^XA^CI28"
@@ -132,3 +140,19 @@ def postlogistics_send_shipping(self, pickings):
132140
pick._generate_postlogistics_label()
133141

134142
return [{"exact_price": False, "tracking_number": False}]
143+
144+
def verify_credentials(self):
145+
access_token = PostlogisticsWebService.get_access_token(self)
146+
if not access_token:
147+
# Error has already been risen
148+
return
149+
message = {
150+
"type": "ir.actions.client",
151+
"tag": "display_notification",
152+
"params": {
153+
"title": _("Validated"),
154+
"message": _("The credential is valid."),
155+
"sticky": False,
156+
},
157+
}
158+
return message

delivery_postlogistics/models/postlogistics_carrier_template_options.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,6 @@ class DeliveryCarrierTemplateOption(models.Model):
2727
help="Allow to define a more complete description than in the name field.",
2828
)
2929
postlogistics_type = fields.Selection(
30-
selection=POSTLOGISTICS_TYPES, string="PostLogistics option type",
30+
selection=POSTLOGISTICS_TYPES,
31+
string="PostLogistics option type",
3132
)
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
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 fields, models
55

66

77
class PostlogisticsShippingLabel(models.Model):
@@ -18,27 +18,3 @@ class PostlogisticsShippingLabel(models.Model):
1818
required=True,
1919
ondelete="cascade",
2020
)
21-
22-
# TODO: check if we can remove this method
23-
@api.model
24-
def _selection_file_type(self):
25-
""" Return a concatenated list of extensions of label file format
26-
plus file format from super
27-
28-
This will be filtered and sorted in __get_file_type_selection
29-
30-
:return: list of tuple (code, name)
31-
32-
"""
33-
file_types = super()._selection_file_type()
34-
new_types = [
35-
("eps", "EPS"),
36-
("gif", "GIF"),
37-
("jpg", "JPG"),
38-
("png", "PNG"),
39-
("pdf", "PDF"),
40-
("spdf", "sPDF"), # sPDF is a pdf without integrated font
41-
("zpl2", "ZPL2"),
42-
]
43-
file_types.extend(new_types)
44-
return file_types

delivery_postlogistics/models/stock_picking.py

+7-10
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,16 @@ def attach_shipping_label(self, label):
7373
)
7474

7575
def _set_a_default_package(self):
76-
""" Pickings using this module must have a package
77-
If not this method put it one silently
76+
"""Pickings using this module must have a package
77+
If not this method put it one silently
7878
"""
7979
for picking in self:
8080
move_lines = picking.move_line_ids.filtered(
8181
lambda s: not (s.package_id or s.result_package_id)
8282
)
8383
if move_lines:
84-
default_packaging = (
85-
picking.carrier_id.postlogistics_default_packaging_id
86-
)
84+
carrier = picking.carrier_id
85+
default_packaging = carrier.postlogistics_default_packaging_id
8786
package = self.env["stock.quant.package"].create(
8887
{
8988
"packaging_id": default_packaging
@@ -94,7 +93,7 @@ def _set_a_default_package(self):
9493
move_lines.write({"result_package_id": package.id})
9594

9695
def postlogistics_cod_amount(self):
97-
""" Return the PostLogistics Cash on Delivery amount of a picking
96+
"""Return the PostLogistics Cash on Delivery amount of a picking
9897
9998
If the picking delivers the whole sales order, we use the total
10099
amount of the sales order.
@@ -115,10 +114,8 @@ def postlogistics_cod_amount(self):
115114
"from different sales orders."
116115
)
117116
)
118-
order_moves = order.mapped("order_line.procurement_ids.move_ids")
119-
picking_moves = self.move_lines
120117
# check if the package delivers the whole sales order
121-
if order_moves != picking_moves:
118+
if len(order.picking_ids) > 1:
122119
raise exceptions.Warning(
123120
_(
124121
"The cash on delivery amount must be manually specified "
@@ -228,7 +225,7 @@ def _generate_postlogistics_label(
228225
if failed_label_results:
229226
# Commit the change to save the changes,
230227
# This ensures the label pushed recored correctly in Odoo
231-
self._cr.commit()
228+
self._cr.commit() # pylint: disable=invalid-commit
232229
error_message = "\n".join(label["errors"] for label in failed_label_results)
233230
raise exceptions.Warning(error_message)
234231
return labels

delivery_postlogistics/models/stock_quant_package.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ class StockQuantPackage(models.Model):
1212
"than the total of the sales order, write the amount there.",
1313
)
1414
parcel_tracking = fields.Char("Parcel Tracking")
15-
package_carrier_type = fields.Selection(related="packaging_id.package_carrier_type")
15+
package_carrier_type = fields.Selection(
16+
related="packaging_id.package_carrier_type",
17+
string="Packaging's Carrier",
18+
)
1619

1720
@api.returns("stock.picking")
1821
def _get_origin_pickings(self):
@@ -22,7 +25,7 @@ def _get_origin_pickings(self):
2225
return move_line.mapped("picking_id.sale_id.picking_ids")
2326

2427
def postlogistics_cod_amount(self):
25-
""" Return the PostLogistics Cash on Delivery amount of a package
28+
"""Return the PostLogistics Cash on Delivery amount of a package
2629
2730
If we have only 1 package which delivers the whole sales order
2831
we use the total amount of the sales order.

0 commit comments

Comments
 (0)