Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Tryton
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tryton
Tryton
Commits
c86889cf
Commit
c86889cf
authored
4 years ago
by
Cédric Krier
Browse files
Options
Downloads
Patches
Plain Diff
Add tracking URL
issue10136 review341531002
parent
8806c086
Loading
Loading
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
__init__.py
+1
-0
1 addition, 0 deletions
__init__.py
stock.py
+38
-0
38 additions, 0 deletions
stock.py
tests/scenario_shipping_dpd.rst
+4
-0
4 additions, 0 deletions
tests/scenario_shipping_dpd.rst
with
43 additions
and
0 deletions
__init__.py
+
1
−
0
View file @
c86889cf
...
...
@@ -11,6 +11,7 @@
Pool
.
register
(
carrier
.
CredentialDPD
,
carrier
.
Carrier
,
stock
.
Package
,
stock
.
ShipmentOut
,
stock
.
ShipmentInReturn
,
module
=
'
stock_package_shipping_dpd
'
,
type_
=
'
model
'
)
...
...
This diff is collapsed.
Click to expand it.
stock.py
+
38
−
0
View file @
c86889cf
...
...
@@ -22,6 +22,44 @@
from
.configuration
import
get_client
,
SHIPMENT_SERVICE
from
.exceptions
import
DPDError
TRACKING_URL
=
'
https://tracking.dpd.de/status/%(code)s/parcel/%(reference)s
'
class
Package
(
metaclass
=
PoolMeta
):
__name__
=
'
stock.package
'
def
get_shipping_tracking_url
(
self
,
name
):
pool
=
Pool
()
ShipmentOut
=
pool
.
get
(
'
stock.shipment.out
'
)
ShipmentInReturn
=
pool
.
get
(
'
stock.shipment.in.return
'
)
url
=
super
().
get_shipping_tracking_url
(
name
)
if
(
self
.
shipping_reference
and
self
.
shipment
and
self
.
shipment
.
id
>=
0
and
self
.
shipment
.
carrier
and
self
.
shipment
.
carrier
.
shipping_service
==
'
dpd
'
):
party
=
address
=
None
if
isinstance
(
self
.
shipment
,
ShipmentOut
):
party
=
self
.
shipment
.
customer
address
=
self
.
shipment
.
delivery_address
elif
isinstance
(
self
.
shipment
,
ShipmentInReturn
):
party
=
self
.
shipment
.
supplier
address
=
self
.
shipment
.
delivery_address
if
party
and
party
.
lang
:
lang_code
=
party
.
lang
.
code
else
:
lang_code
=
Transaction
().
language
if
address
and
address
.
country
:
code
=
'
_
'
.
join
(
(
lang_code
.
split
(
'
_
'
)[
0
],
address
.
country
.
code
))
else
:
code
=
lang_code
url
=
TRACKING_URL
%
{
'
code
'
:
code
,
'
reference
'
:
self
.
shipping_reference
,
}
return
url
class
ShippingDPDMixin
:
...
...
This diff is collapsed.
Click to expand it.
tests/scenario_shipping_dpd.rst
+
4
−
0
View file @
c86889cf
...
...
@@ -222,3 +222,7 @@
True
>>> pack.shipping_reference is not None
True
>>> pack.shipping_tracking_url.startswith('https://tracking.dpd.de/status/')
True
>>> pack.shipping_tracking_url.endswith(pack.shipping_reference)
True
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment