From f0d4d84db54bff9891607100ef60f968f92faa5e Mon Sep 17 00:00:00 2001 From: Ashutosh singh <55102089+Ashutosh619-sudo@users.noreply.github.com> Date: Wed, 3 Jul 2024 13:18:24 +0530 Subject: [PATCH] Ignore vendor when display name not present (#147) * Ignore vendor when display name not present * comment resolved * resolve comment * comment resolved * comment resolved * comment resolved --- apps/business_central/utils.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/apps/business_central/utils.py b/apps/business_central/utils.py index 8182037..7ad320c 100644 --- a/apps/business_central/utils.py +++ b/apps/business_central/utils.py @@ -70,6 +70,14 @@ def _sync_data(self, data, attribute_type, display_name, workspace_id, field_nam destination_attributes = [] for item in data: + value = None + if 'displayName' in item and item['displayName']: + value = item['displayName'] + elif 'name' in item and item['name']: + value = item['name'] + + if not value: + continue detail = {field: item[field] for field in field_names} if (attribute_type == 'EMPLOYEE' and item.get('status') == 'Active') or (attribute_type in ('LOCATION', 'COMPANY')) or (item.get('blocked') is not None and item.get('blocked') != True): active = True @@ -81,7 +89,7 @@ def _sync_data(self, data, attribute_type, display_name, workspace_id, field_nam destination_attributes.append(self._create_destination_attribute( attribute_type, display_name, - item['displayName'] if item['displayName'] else item['name'], + value, item['number'] if item.get('number') else item['id'], active, detail