odoo-addon-delivery-ups-oca 17.0.1.0.0.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. odoo/addons/delivery_ups_oca/README.rst +147 -0
  2. odoo/addons/delivery_ups_oca/__init__.py +3 -0
  3. odoo/addons/delivery_ups_oca/__manifest__.py +26 -0
  4. odoo/addons/delivery_ups_oca/data/stock_package_type_data.xml +120 -0
  5. odoo/addons/delivery_ups_oca/i18n/delivery_ups_oca.pot +399 -0
  6. odoo/addons/delivery_ups_oca/i18n/it.po +471 -0
  7. odoo/addons/delivery_ups_oca/models/__init__.py +5 -0
  8. odoo/addons/delivery_ups_oca/models/delivery_carrier.py +213 -0
  9. odoo/addons/delivery_ups_oca/models/stock_package_type.py +9 -0
  10. odoo/addons/delivery_ups_oca/models/stock_picking.py +14 -0
  11. odoo/addons/delivery_ups_oca/models/ups_request.py +415 -0
  12. odoo/addons/delivery_ups_oca/readme/CONFIGURE.md +17 -0
  13. odoo/addons/delivery_ups_oca/readme/CONTRIBUTORS.md +9 -0
  14. odoo/addons/delivery_ups_oca/readme/DESCRIPTION.md +10 -0
  15. odoo/addons/delivery_ups_oca/readme/ROADMAP.md +2 -0
  16. odoo/addons/delivery_ups_oca/readme/USAGE.md +12 -0
  17. odoo/addons/delivery_ups_oca/static/description/icon.png +0 -0
  18. odoo/addons/delivery_ups_oca/static/description/index.html +498 -0
  19. odoo/addons/delivery_ups_oca/tests/__init__.py +3 -0
  20. odoo/addons/delivery_ups_oca/tests/test_delivery_ups.py +165 -0
  21. odoo/addons/delivery_ups_oca/views/delivery_carrier_view.xml +84 -0
  22. odoo/addons/delivery_ups_oca/views/stock_picking_view.xml +24 -0
  23. odoo_addon_delivery_ups_oca-17.0.1.0.0.2.dist-info/METADATA +166 -0
  24. odoo_addon_delivery_ups_oca-17.0.1.0.0.2.dist-info/RECORD +26 -0
  25. odoo_addon_delivery_ups_oca-17.0.1.0.0.2.dist-info/WHEEL +5 -0
  26. odoo_addon_delivery_ups_oca-17.0.1.0.0.2.dist-info/top_level.txt +1 -0
@@ -0,0 +1,498 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5
+ <meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
6
+ <title>README.rst</title>
7
+ <style type="text/css">
8
+
9
+ /*
10
+ :Author: David Goodger (goodger@python.org)
11
+ :Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
12
+ :Copyright: This stylesheet has been placed in the public domain.
13
+
14
+ Default cascading style sheet for the HTML output of Docutils.
15
+ Despite the name, some widely supported CSS2 features are used.
16
+
17
+ See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
18
+ customize this style sheet.
19
+ */
20
+
21
+ /* used to remove borders from tables and images */
22
+ .borderless, table.borderless td, table.borderless th {
23
+ border: 0 }
24
+
25
+ table.borderless td, table.borderless th {
26
+ /* Override padding for "table.docutils td" with "! important".
27
+ The right padding separates the table cells. */
28
+ padding: 0 0.5em 0 0 ! important }
29
+
30
+ .first {
31
+ /* Override more specific margin styles with "! important". */
32
+ margin-top: 0 ! important }
33
+
34
+ .last, .with-subtitle {
35
+ margin-bottom: 0 ! important }
36
+
37
+ .hidden {
38
+ display: none }
39
+
40
+ .subscript {
41
+ vertical-align: sub;
42
+ font-size: smaller }
43
+
44
+ .superscript {
45
+ vertical-align: super;
46
+ font-size: smaller }
47
+
48
+ a.toc-backref {
49
+ text-decoration: none ;
50
+ color: black }
51
+
52
+ blockquote.epigraph {
53
+ margin: 2em 5em ; }
54
+
55
+ dl.docutils dd {
56
+ margin-bottom: 0.5em }
57
+
58
+ object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] {
59
+ overflow: hidden;
60
+ }
61
+
62
+ /* Uncomment (and remove this text!) to get bold-faced definition list terms
63
+ dl.docutils dt {
64
+ font-weight: bold }
65
+ */
66
+
67
+ div.abstract {
68
+ margin: 2em 5em }
69
+
70
+ div.abstract p.topic-title {
71
+ font-weight: bold ;
72
+ text-align: center }
73
+
74
+ div.admonition, div.attention, div.caution, div.danger, div.error,
75
+ div.hint, div.important, div.note, div.tip, div.warning {
76
+ margin: 2em ;
77
+ border: medium outset ;
78
+ padding: 1em }
79
+
80
+ div.admonition p.admonition-title, div.hint p.admonition-title,
81
+ div.important p.admonition-title, div.note p.admonition-title,
82
+ div.tip p.admonition-title {
83
+ font-weight: bold ;
84
+ font-family: sans-serif }
85
+
86
+ div.attention p.admonition-title, div.caution p.admonition-title,
87
+ div.danger p.admonition-title, div.error p.admonition-title,
88
+ div.warning p.admonition-title, .code .error {
89
+ color: red ;
90
+ font-weight: bold ;
91
+ font-family: sans-serif }
92
+
93
+ /* Uncomment (and remove this text!) to get reduced vertical space in
94
+ compound paragraphs.
95
+ div.compound .compound-first, div.compound .compound-middle {
96
+ margin-bottom: 0.5em }
97
+
98
+ div.compound .compound-last, div.compound .compound-middle {
99
+ margin-top: 0.5em }
100
+ */
101
+
102
+ div.dedication {
103
+ margin: 2em 5em ;
104
+ text-align: center ;
105
+ font-style: italic }
106
+
107
+ div.dedication p.topic-title {
108
+ font-weight: bold ;
109
+ font-style: normal }
110
+
111
+ div.figure {
112
+ margin-left: 2em ;
113
+ margin-right: 2em }
114
+
115
+ div.footer, div.header {
116
+ clear: both;
117
+ font-size: smaller }
118
+
119
+ div.line-block {
120
+ display: block ;
121
+ margin-top: 1em ;
122
+ margin-bottom: 1em }
123
+
124
+ div.line-block div.line-block {
125
+ margin-top: 0 ;
126
+ margin-bottom: 0 ;
127
+ margin-left: 1.5em }
128
+
129
+ div.sidebar {
130
+ margin: 0 0 0.5em 1em ;
131
+ border: medium outset ;
132
+ padding: 1em ;
133
+ background-color: #ffffee ;
134
+ width: 40% ;
135
+ float: right ;
136
+ clear: right }
137
+
138
+ div.sidebar p.rubric {
139
+ font-family: sans-serif ;
140
+ font-size: medium }
141
+
142
+ div.system-messages {
143
+ margin: 5em }
144
+
145
+ div.system-messages h1 {
146
+ color: red }
147
+
148
+ div.system-message {
149
+ border: medium outset ;
150
+ padding: 1em }
151
+
152
+ div.system-message p.system-message-title {
153
+ color: red ;
154
+ font-weight: bold }
155
+
156
+ div.topic {
157
+ margin: 2em }
158
+
159
+ h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
160
+ h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
161
+ margin-top: 0.4em }
162
+
163
+ h1.title {
164
+ text-align: center }
165
+
166
+ h2.subtitle {
167
+ text-align: center }
168
+
169
+ hr.docutils {
170
+ width: 75% }
171
+
172
+ img.align-left, .figure.align-left, object.align-left, table.align-left {
173
+ clear: left ;
174
+ float: left ;
175
+ margin-right: 1em }
176
+
177
+ img.align-right, .figure.align-right, object.align-right, table.align-right {
178
+ clear: right ;
179
+ float: right ;
180
+ margin-left: 1em }
181
+
182
+ img.align-center, .figure.align-center, object.align-center {
183
+ display: block;
184
+ margin-left: auto;
185
+ margin-right: auto;
186
+ }
187
+
188
+ table.align-center {
189
+ margin-left: auto;
190
+ margin-right: auto;
191
+ }
192
+
193
+ .align-left {
194
+ text-align: left }
195
+
196
+ .align-center {
197
+ clear: both ;
198
+ text-align: center }
199
+
200
+ .align-right {
201
+ text-align: right }
202
+
203
+ /* reset inner alignment in figures */
204
+ div.align-right {
205
+ text-align: inherit }
206
+
207
+ /* div.align-center * { */
208
+ /* text-align: left } */
209
+
210
+ .align-top {
211
+ vertical-align: top }
212
+
213
+ .align-middle {
214
+ vertical-align: middle }
215
+
216
+ .align-bottom {
217
+ vertical-align: bottom }
218
+
219
+ ol.simple, ul.simple {
220
+ margin-bottom: 1em }
221
+
222
+ ol.arabic {
223
+ list-style: decimal }
224
+
225
+ ol.loweralpha {
226
+ list-style: lower-alpha }
227
+
228
+ ol.upperalpha {
229
+ list-style: upper-alpha }
230
+
231
+ ol.lowerroman {
232
+ list-style: lower-roman }
233
+
234
+ ol.upperroman {
235
+ list-style: upper-roman }
236
+
237
+ p.attribution {
238
+ text-align: right ;
239
+ margin-left: 50% }
240
+
241
+ p.caption {
242
+ font-style: italic }
243
+
244
+ p.credits {
245
+ font-style: italic ;
246
+ font-size: smaller }
247
+
248
+ p.label {
249
+ white-space: nowrap }
250
+
251
+ p.rubric {
252
+ font-weight: bold ;
253
+ font-size: larger ;
254
+ color: maroon ;
255
+ text-align: center }
256
+
257
+ p.sidebar-title {
258
+ font-family: sans-serif ;
259
+ font-weight: bold ;
260
+ font-size: larger }
261
+
262
+ p.sidebar-subtitle {
263
+ font-family: sans-serif ;
264
+ font-weight: bold }
265
+
266
+ p.topic-title {
267
+ font-weight: bold }
268
+
269
+ pre.address {
270
+ margin-bottom: 0 ;
271
+ margin-top: 0 ;
272
+ font: inherit }
273
+
274
+ pre.literal-block, pre.doctest-block, pre.math, pre.code {
275
+ margin-left: 2em ;
276
+ margin-right: 2em }
277
+
278
+ pre.code .ln { color: gray; } /* line numbers */
279
+ pre.code, code { background-color: #eeeeee }
280
+ pre.code .comment, code .comment { color: #5C6576 }
281
+ pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
282
+ pre.code .literal.string, code .literal.string { color: #0C5404 }
283
+ pre.code .name.builtin, code .name.builtin { color: #352B84 }
284
+ pre.code .deleted, code .deleted { background-color: #DEB0A1}
285
+ pre.code .inserted, code .inserted { background-color: #A3D289}
286
+
287
+ span.classifier {
288
+ font-family: sans-serif ;
289
+ font-style: oblique }
290
+
291
+ span.classifier-delimiter {
292
+ font-family: sans-serif ;
293
+ font-weight: bold }
294
+
295
+ span.interpreted {
296
+ font-family: sans-serif }
297
+
298
+ span.option {
299
+ white-space: nowrap }
300
+
301
+ span.pre {
302
+ white-space: pre }
303
+
304
+ span.problematic, pre.problematic {
305
+ color: red }
306
+
307
+ span.section-subtitle {
308
+ /* font-size relative to parent (h1..h6 element) */
309
+ font-size: 80% }
310
+
311
+ table.citation {
312
+ border-left: solid 1px gray;
313
+ margin-left: 1px }
314
+
315
+ table.docinfo {
316
+ margin: 2em 4em }
317
+
318
+ table.docutils {
319
+ margin-top: 0.5em ;
320
+ margin-bottom: 0.5em }
321
+
322
+ table.footnote {
323
+ border-left: solid 1px black;
324
+ margin-left: 1px }
325
+
326
+ table.docutils td, table.docutils th,
327
+ table.docinfo td, table.docinfo th {
328
+ padding-left: 0.5em ;
329
+ padding-right: 0.5em ;
330
+ vertical-align: top }
331
+
332
+ table.docutils th.field-name, table.docinfo th.docinfo-name {
333
+ font-weight: bold ;
334
+ text-align: left ;
335
+ white-space: nowrap ;
336
+ padding-left: 0 }
337
+
338
+ /* "booktabs" style (no vertical lines) */
339
+ table.docutils.booktabs {
340
+ border: 0px;
341
+ border-top: 2px solid;
342
+ border-bottom: 2px solid;
343
+ border-collapse: collapse;
344
+ }
345
+ table.docutils.booktabs * {
346
+ border: 0px;
347
+ }
348
+ table.docutils.booktabs th {
349
+ border-bottom: thin solid;
350
+ text-align: left;
351
+ }
352
+
353
+ h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
354
+ h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
355
+ font-size: 100% }
356
+
357
+ ul.auto-toc {
358
+ list-style-type: none }
359
+
360
+ </style>
361
+ </head>
362
+ <body>
363
+ <div class="document">
364
+
365
+
366
+ <a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
367
+ <img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
368
+ </a>
369
+ <div class="section" id="delivery-ups-oca">
370
+ <h1>Delivery UPS OCA</h1>
371
+ <!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
372
+ !! This file is generated by oca-gen-addon-readme !!
373
+ !! changes will be overwritten. !!
374
+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
375
+ !! source digest: sha256:5c5c1b09dfe20724c425c5b6c39f037b475f251b53e312baa365316b53fad92d
376
+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
377
+ <p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/delivery-carrier/tree/17.0/delivery_ups_oca"><img alt="OCA/delivery-carrier" src="https://img.shields.io/badge/github-OCA%2Fdelivery--carrier-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/delivery-carrier-17-0/delivery-carrier-17-0-delivery_ups_oca"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/delivery-carrier&amp;target_branch=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
378
+ <p>This module adds <a class="reference external" href="https://ups.com">UPS</a> to the available carriers.</p>
379
+ <p>It allows you to register shippings, generate labels, get rates from
380
+ order, read shipping states and cancel shipments using UPS webservice,
381
+ so no need of exchanging any kind of file.</p>
382
+ <p>When a sales order is created in Odoo and the UPS carrier is assigned,
383
+ the shipping price that will be obtained will be the price that the UPS
384
+ webservice estimates according to the order information (address and
385
+ products).</p>
386
+ <p><strong>Table of contents</strong></p>
387
+ <div class="contents local topic" id="contents">
388
+ <ul class="simple">
389
+ <li><a class="reference internal" href="#configuration" id="toc-entry-1">Configuration</a></li>
390
+ <li><a class="reference internal" href="#usage" id="toc-entry-2">Usage</a></li>
391
+ <li><a class="reference internal" href="#known-issues-roadmap" id="toc-entry-3">Known issues / Roadmap</a></li>
392
+ <li><a class="reference internal" href="#bug-tracker" id="toc-entry-4">Bug Tracker</a></li>
393
+ <li><a class="reference internal" href="#credits" id="toc-entry-5">Credits</a><ul>
394
+ <li><a class="reference internal" href="#authors" id="toc-entry-6">Authors</a></li>
395
+ <li><a class="reference internal" href="#contributors" id="toc-entry-7">Contributors</a></li>
396
+ <li><a class="reference internal" href="#maintainers" id="toc-entry-8">Maintainers</a></li>
397
+ </ul>
398
+ </li>
399
+ </ul>
400
+ </div>
401
+ <div class="section" id="configuration">
402
+ <h2><a class="toc-backref" href="#toc-entry-1">Configuration</a></h2>
403
+ <p>To configure this module, you need to:</p>
404
+ <ol class="arabic simple">
405
+ <li>Add a Shipping Method with Provider <tt class="docutils literal">UPS</tt> and fill in your UPS
406
+ credentials (Client ID and Client Secret)</li>
407
+ <li>Configure in Odoo all required fields of the UPS tab with your
408
+ account data <a class="reference external" href="https://wwwapps.ups.com/ppc/ppc.html">https://wwwapps.ups.com/ppc/ppc.html</a> (Shipper number,
409
+ Default Packaging, Package Dimension Code, Package Weight Code and
410
+ File Format).</li>
411
+ <li>If yo have “Tracking state update sync” checked all delivery orders
412
+ state check will be done querying UPS services.</li>
413
+ <li>It is possible to create a UPS carrier for cash on delivery parcels.
414
+ Select the <tt class="docutils literal">ups</tt> delivery type and check the “Cash on Delivery”
415
+ checkbox under the “UPS” tab. It is required to select the “UPS COD
416
+ Funds Code” when the “Cash on Delivery” option is selected.</li>
417
+ </ol>
418
+ <p><strong>NOTE</strong> You need to add an APP from <a class="reference external" href="https://developer.ups.com/">https://developer.ups.com/</a> for
419
+ using the webservice.</p>
420
+ </div>
421
+ <div class="section" id="usage">
422
+ <h2><a class="toc-backref" href="#toc-entry-2">Usage</a></h2>
423
+ <p>You have to set the created shipping method in the delivery order to
424
+ ship:</p>
425
+ <ul class="simple">
426
+ <li>When the picking is ‘Transferred’, a <em>Create Shipping Label</em> button
427
+ appears. Just click on it, and if all went well, the label will be
428
+ ‘attached’.</li>
429
+ <li>If the shipment creation process fails, a validation error will appear
430
+ displaying UPS error.</li>
431
+ <li>When the delivery order is cancelled, it’s automatically cancelled too
432
+ in UPS.</li>
433
+ <li>If you have “Tracking state update sync” checked in the shipping
434
+ method, a periodical state check will be done querying UPS services.</li>
435
+ </ul>
436
+ </div>
437
+ <div class="section" id="known-issues-roadmap">
438
+ <h2><a class="toc-backref" href="#toc-entry-3">Known issues / Roadmap</a></h2>
439
+ <ul class="simple">
440
+ <li>Support international forms</li>
441
+ <li>Support package service options</li>
442
+ </ul>
443
+ </div>
444
+ <div class="section" id="bug-tracker">
445
+ <h2><a class="toc-backref" href="#toc-entry-4">Bug Tracker</a></h2>
446
+ <p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/delivery-carrier/issues">GitHub Issues</a>.
447
+ In case of trouble, please check there if your issue has already been reported.
448
+ If you spotted it first, help us to smash it by providing a detailed and welcomed
449
+ <a class="reference external" href="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**">feedback</a>.</p>
450
+ <p>Do not contact contributors directly about support or help with technical issues.</p>
451
+ </div>
452
+ <div class="section" id="credits">
453
+ <h2><a class="toc-backref" href="#toc-entry-5">Credits</a></h2>
454
+ <div class="section" id="authors">
455
+ <h3><a class="toc-backref" href="#toc-entry-6">Authors</a></h3>
456
+ <ul class="simple">
457
+ <li>Hunki Enterprises BV</li>
458
+ <li>Tecnativa</li>
459
+ <li>ForgeFlow</li>
460
+ </ul>
461
+ </div>
462
+ <div class="section" id="contributors">
463
+ <h3><a class="toc-backref" href="#toc-entry-7">Contributors</a></h3>
464
+ <ul class="simple">
465
+ <li>Holger Brunn &lt;<a class="reference external" href="mailto:mail&#64;hunki-enterprises.nl">mail&#64;hunki-enterprises.nl</a>&gt;
466
+ (<a class="reference external" href="https://hunki-enterprises.nl">https://hunki-enterprises.nl</a>)</li>
467
+ <li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:<ul>
468
+ <li>Víctor Martínez</li>
469
+ <li>Pedro M. Baeza</li>
470
+ </ul>
471
+ </li>
472
+ <li><a class="reference external" href="https://www.forgeflow.com">ForgeFlow</a>:<ul>
473
+ <li>Jordi Ballester</li>
474
+ </ul>
475
+ </li>
476
+ <li><a class="reference external" href="https://www.sygel.es">Sygel</a>:<ul>
477
+ <li>Manuel Regidor</li>
478
+ </ul>
479
+ </li>
480
+ </ul>
481
+ </div>
482
+ <div class="section" id="maintainers">
483
+ <h3><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h3>
484
+ <p>This module is maintained by the OCA.</p>
485
+ <a class="reference external image-reference" href="https://odoo-community.org">
486
+ <img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
487
+ </a>
488
+ <p>OCA, or the Odoo Community Association, is a nonprofit organization whose
489
+ mission is to support the collaborative development of Odoo features and
490
+ promote its widespread use.</p>
491
+ <p>This module is part of the <a class="reference external" href="https://github.com/OCA/delivery-carrier/tree/17.0/delivery_ups_oca">OCA/delivery-carrier</a> project on GitHub.</p>
492
+ <p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
493
+ </div>
494
+ </div>
495
+ </div>
496
+ </div>
497
+ </body>
498
+ </html>
@@ -0,0 +1,3 @@
1
+ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
2
+
3
+ from . import test_delivery_ups
@@ -0,0 +1,165 @@
1
+ # Copyright 2020 Hunki Enterprises BV
2
+ # Copyright 2021-2022 Tecnativa - Víctor Martínez
3
+ # Copyright 2024 Sygel - Manuel Regidor
4
+ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
5
+
6
+ import base64
7
+ from unittest import mock
8
+
9
+ from odoo.tests import Form, common
10
+
11
+ _module_ns = "odoo.addons.delivery_ups_oca"
12
+ _provider_class = _module_ns + ".models.ups_request.UpsRequest"
13
+
14
+
15
+ class TestDeliveryUpsBase(common.TransactionCase):
16
+ @classmethod
17
+ def setUpClass(cls):
18
+ super().setUpClass()
19
+ product_shipping_cost = cls.env["product.product"].create(
20
+ {
21
+ "type": "service",
22
+ "name": "Shipping costs",
23
+ "standard_price": 10,
24
+ "list_price": 100,
25
+ }
26
+ )
27
+ cls.carrier = cls.env["delivery.carrier"].create(
28
+ {
29
+ "name": "UPS",
30
+ "delivery_type": "ups",
31
+ "product_id": product_shipping_cost.id,
32
+ "price_method": "fixed",
33
+ "ups_default_packaging_id": cls.env.ref(
34
+ "delivery_ups_oca.product_packaging_ups_02"
35
+ ).id,
36
+ }
37
+ )
38
+ cls.company = cls.env.ref("base.main_company")
39
+ cls.company.partner_id.write(
40
+ {
41
+ "phone": "+%s976123456" % cls.company.country_id.phone_code,
42
+ "vat": "%s09915370R" % cls.company.country_id.code,
43
+ }
44
+ )
45
+ cls.partner = cls.env["res.partner"].create(
46
+ {
47
+ "name": "Test partner",
48
+ "country_id": cls.company.country_id.id,
49
+ "phone": cls.company.partner_id.phone,
50
+ "email": "test@odoo.com",
51
+ "street": cls.company.partner_id.street,
52
+ "city": cls.company.partner_id.city,
53
+ "zip": cls.company.partner_id.zip,
54
+ "state_id": cls.company.partner_id.state_id.id,
55
+ "vat": cls.company.partner_id.vat,
56
+ }
57
+ )
58
+ cls.product = cls.env["product.product"].create(
59
+ {"name": "Test product", "type": "product", "weight": 10}
60
+ )
61
+ cls.sale = cls._create_sale_order(cls)
62
+
63
+ def _create_sale_order(self):
64
+ order_form = Form(self.env["sale.order"])
65
+ order_form.partner_id = self.partner
66
+ with order_form.order_line.new() as line_form:
67
+ line_form.product_id = self.product
68
+ line_form.product_uom_qty = 10
69
+ sale = order_form.save()
70
+ delivery_wizard = Form(
71
+ self.env["choose.delivery.carrier"].with_context(
72
+ **{"default_order_id": sale.id, "default_carrier_id": self.carrier.id}
73
+ )
74
+ ).save()
75
+ delivery_wizard.button_confirm()
76
+ sale.action_confirm()
77
+ return sale
78
+
79
+
80
+ class TestDeliveryUps(TestDeliveryUpsBase):
81
+ @classmethod
82
+ def setUpClass(cls):
83
+ super().setUpClass()
84
+ cls.picking = cls.sale.picking_ids[0]
85
+ cls.picking.move_ids.quantity = 10
86
+
87
+ def test_order_ups_rate_shipment(self):
88
+ with mock.patch(
89
+ _provider_class + "._rate_shipment",
90
+ return_value={
91
+ "RateResponse": {
92
+ "RatedShipment": {
93
+ "TotalCharges": {"MonetaryValue": 1, "CurrencyCode": "USD"}
94
+ }
95
+ }
96
+ },
97
+ ):
98
+ res = self.carrier.ups_rate_shipment(self.sale)
99
+ self.assertGreater(res["price"], 0)
100
+ self.assertTrue(res["success"])
101
+
102
+ def test_order_ups_rate_shipment_currency_extra(self):
103
+ usd = self.env.ref("base.USD")
104
+ eur = self.env.ref("base.EUR")
105
+ currency = self.env.ref("base.main_company").currency_id
106
+ currency_extra = eur if currency == usd else usd
107
+ self.sale.currency_id = currency_extra
108
+ with mock.patch(
109
+ _provider_class + "._rate_shipment",
110
+ return_value={
111
+ "RateResponse": {
112
+ "RatedShipment": {
113
+ "TotalCharges": {"MonetaryValue": 1, "CurrencyCode": "USD"}
114
+ }
115
+ }
116
+ },
117
+ ):
118
+ res = self.carrier.ups_rate_shipment(self.sale)
119
+ self.assertGreater(res["price"], 0)
120
+ self.assertTrue(res["success"])
121
+
122
+ def test_delivery_carrier_ups_integration(self):
123
+ self.picking.action_confirm()
124
+ self.picking.action_assign()
125
+ # Create a simple PDF-like bytes object for testing
126
+ label = b"%PDF-1.4\n%EOF"
127
+ with mock.patch(
128
+ _provider_class + "._send_shipping",
129
+ return_value={
130
+ "price": {"CurrencyCode": "USD", "MonetaryValue": "0.0"},
131
+ "ShipmentIdentificationNumber": "123456",
132
+ "labels": [
133
+ {
134
+ "tracking_ref": "123456",
135
+ "format_code": "png",
136
+ "datas": base64.b64encode(label),
137
+ }
138
+ ],
139
+ },
140
+ ):
141
+ self.picking.send_to_shipper()
142
+ self.assertEqual(self.picking.message_attachment_count, 1)
143
+ self.assertTrue(self.picking.carrier_tracking_ref)
144
+ self.assertFalse(self.picking.tracking_state_history)
145
+ self.assertEqual(
146
+ self.picking.delivery_state, "shipping_recorded_in_carrier"
147
+ )
148
+ if self.picking.carrier_id.ups_tracking_state_update_sync:
149
+ with mock.patch(
150
+ _provider_class + ".tracking_state_update",
151
+ return_value={
152
+ "delivery_state": "in_transit",
153
+ "tracking_state_history": "history",
154
+ },
155
+ ):
156
+ self.picking.tracking_state_update()
157
+ self.assertEqual(self.picking.delivery_state, "in_transit")
158
+ self.assertTrue(self.picking.tracking_state_history)
159
+ with mock.patch(
160
+ _provider_class + ".cancel_shipment",
161
+ return_value=True,
162
+ ):
163
+ self.picking.cancel_shipment()
164
+ self.assertFalse(self.picking.carrier_tracking_ref)
165
+ self.assertEqual(self.picking.delivery_state, "canceled_shipment")