From 5184b720518976bb0d5d04305479a14dcf37963f Mon Sep 17 00:00:00 2001 From: Hrishabh Tiwari Date: Fri, 19 Jul 2024 15:27:32 +0530 Subject: [PATCH] change the callback methods are sent --- apps/sage300/utils.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/apps/sage300/utils.py b/apps/sage300/utils.py index e957027..572aa3b 100644 --- a/apps/sage300/utils.py +++ b/apps/sage300/utils.py @@ -1,6 +1,6 @@ import logging from django.utils.module_loading import import_string -from fyle_accounting_mappings.models import DestinationAttribute +from fyle_accounting_mappings.models import DestinationAttribute, MappingSetting from apps.workspaces.models import Sage300Credential from sage_desktop_sdk.sage_desktop_sdk import SageDesktopSDK from apps.sage300.models import CostCategory @@ -12,9 +12,9 @@ ATTRIBUTE_CALLBACK_MAP = { - 'JOB': 'apps.sage300.helpers.disable_projects', - 'ACCOUNT': 'apps.mappings.imports.modules.categories.disable_categories', - 'VENDOR': 'apps.mappings.imports.modules.merchants.disable_merchants', + 'PROJECT': 'apps.sage300.helpers.disable_projects', + 'CATEGORY': 'apps.mappings.imports.modules.categories.disable_categories', + 'MERCHANT': 'apps.mappings.imports.modules.merchants.disable_merchants' } @@ -139,6 +139,10 @@ def _sync_data(self, data_gen, attribute_type, display_name, workspace_id, field :param workspace_id: ID of the workspace :param field_names: Names of fields to include in detail """ + source_type = None + mapping_setting = MappingSetting.objects.filter(workspace_id=workspace_id, destination_field=attribute_type).first() + if mapping_setting: + source_type = mapping_setting.source_field if not mapping_setting.is_custom else 'CUSTOM' if is_generator: for data in data_gen: @@ -151,7 +155,7 @@ def _sync_data(self, data_gen, attribute_type, display_name, workspace_id, field if destination_attr: destination_attributes.append(destination_attr) - if attribute_type in ATTRIBUTE_CALLBACK_MAP.keys(): + if source_type in ATTRIBUTE_CALLBACK_MAP.keys(): DestinationAttribute.bulk_create_or_update_destination_attributes( destination_attributes, attribute_type,