Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UPD] delivery_deliverea: Get partner data info #912

Open
wants to merge 1 commit into
base: 16.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 10 additions & 14 deletions delivery_deliverea/models/delivery_carrier.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,29 +266,25 @@ def _check_mandatory_fields(self, values, mandatory_list, object_id):
% {"field": ", ".join(errors), "object_id": object_id.name}
)

def _get_field_from_partner_or_parent_id(self, partner, field):
return partner[field] or partner.parent_id and partner.parent_id[field] or ""

def _get_deliverea_sender_info(self, partner, request_type):
country_id = self._get_field_from_partner_or_parent_id(partner, "country_id")
state_id = self._get_field_from_partner_or_parent_id(partner, "state_id")
country_id = partner.country_id or ""
state_id = partner.state_id or ""
values = {
"name": self._get_field_from_partner_or_parent_id(partner, "name"),
"name": partner.name or "",
"address": " ".join(
[
self._get_field_from_partner_or_parent_id(partner, "street"),
self._get_field_from_partner_or_parent_id(partner, "street2"),
partner.street or "",
partner.street2 or "",
]
).strip(),
"city": self._get_field_from_partner_or_parent_id(partner, "city"),
"zipCode": self._get_field_from_partner_or_parent_id(partner, "zip"),
"city": partner.city or "",
"zipCode": partner.zip or "",
"countryCode": country_id.code if country_id else "",
"idNumber": self._get_field_from_partner_or_parent_id(partner, "vat"),
"idNumber": partner.vat or "",
"stateCode": state_id.code if state_id else "",
"observations": "",
"phone": self._get_field_from_partner_or_parent_id(partner, "phone")
or self._get_field_from_partner_or_parent_id(partner, "mobile"),
"email": self._get_field_from_partner_or_parent_id(partner, "email"),
"phone": partner.phone or partner.mobile or "",
"email": partner.email or "",
}
self._check_mandatory_fields(
values,
Expand Down
20 changes: 11 additions & 9 deletions delivery_deliverea/models/stock_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,17 @@ def deliverea_update_tracking_state(self, data):
)
picking_id.write(
{
"delivery_state": deliverea_state.delivery_state
if deliverea_state
else False,
"date_delivered": datetime.strftime(
datetime.now(), DEFAULT_SERVER_DATETIME_FORMAT
)
if deliverea_state
and deliverea_state.delivery_state == "customer_delivered"
else False,
"delivery_state": (
deliverea_state.delivery_state if deliverea_state else False
),
"date_delivered": (
datetime.strftime(
datetime.now(), DEFAULT_SERVER_DATETIME_FORMAT
)
if deliverea_state
and deliverea_state.delivery_state == "customer_delivered"
else False
),
"carrier_tracking_url": data.get("advancedTrackingUrl"),
"tracking_state": "[{}] {}".format(
data.get("trackingCode"), data.get("trackingDetails")
Expand Down
Loading