Skip to content

Commit

Permalink
[FIX] delivery_dhl_parcel: show full name
Browse files Browse the repository at this point in the history
If we just show the partner's name there will be cases where we'll be
losing the most important info which is the main organization where the
shipping is sent.

TT49966
  • Loading branch information
chienandalu authored and ioans73 committed Dec 9, 2024
1 parent e780359 commit e0f1756
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion delivery_dhl_parcel/models/delivery_carrier.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,20 @@ def _prepare_dhl_parcel_address_info(self, partner):
address = partner.street or ""
if partner.street2:
address += " " + partner.street2

Check warning on line 75 in delivery_dhl_parcel/models/delivery_carrier.py

View check run for this annotation

Codecov / codecov/patch

delivery_dhl_parcel/models/delivery_carrier.py#L75

Added line #L75 was not covered by tests
partner_name = partner.name
# We have a limit of 40 chars, so we'll try to allocate as much space possible
# for both parent an contact name, trying to use all the available space if
# possible and otherwise, cutting it to 19 chars max (letting 2 chars for
# the separation of both names)
if partner.parent_id:
max_parent_length = min(

Check warning on line 82 in delivery_dhl_parcel/models/delivery_carrier.py

View check run for this annotation

Codecov / codecov/patch

delivery_dhl_parcel/models/delivery_carrier.py#L82

Added line #L82 was not covered by tests
len(partner.parent_id.name), 19 + max(19 - len(partner_name), 0)
)
partner_name = (

Check warning on line 85 in delivery_dhl_parcel/models/delivery_carrier.py

View check run for this annotation

Codecov / codecov/patch

delivery_dhl_parcel/models/delivery_carrier.py#L85

Added line #L85 was not covered by tests
f"{partner.parent_id.name[:max_parent_length]}, {partner_name}"
)
return {
"Name": partner.name or partner.parent_id.name or "",
"Name": partner_name[:40],
"Address": address[:40],
"City": partner.city or "",
"PostalCode": partner.zip or "",
Expand Down

0 comments on commit e0f1756

Please sign in to comment.