Fix: Remove WHERE clauses and cf_854 field from vTiger queries (API doesn't support empty string comparison)

This commit is contained in:
Christian 2025-12-19 15:34:49 +01:00
parent 8bc633d59c
commit 3f66bd07e6

View File

@ -37,7 +37,7 @@ async def sync_from_vtiger() -> Dict[str, Any]:
vtiger = get_vtiger_service()
# Query vTiger for all accounts with CVR or name
query = "SELECT id, accountname, email1, siccode, cf_accounts_cvr, cf_854, website1, bill_city, bill_code, bill_country FROM Accounts WHERE accountname != '' LIMIT 1000;"
query = "SELECT id, accountname, email1, siccode, cf_accounts_cvr, website, bill_city, bill_code, bill_country FROM Accounts LIMIT 1000;"
accounts = await vtiger.query(query)
logger.info(f"📥 Fetched {len(accounts)} accounts from vTiger")
@ -50,7 +50,7 @@ async def sync_from_vtiger() -> Dict[str, Any]:
vtiger_id = account.get('id')
name = account.get('accountname', '').strip()
cvr = account.get('cf_accounts_cvr') or account.get('siccode')
economic_customer_number = account.get('cf_854') # Custom field for e-conomic number
economic_customer_number = None # Will be set by e-conomic sync
if not name:
skipped_count += 1
@ -169,7 +169,7 @@ async def sync_vtiger_contacts() -> Dict[str, Any]:
vtiger = get_vtiger_service()
# Query vTiger for contacts
query = "SELECT id, firstname, lastname, email, phone, mobile, title, department, account_id FROM Contacts WHERE firstname != '' OR lastname != '' LIMIT 1000;"
query = "SELECT id, firstname, lastname, email, phone, mobile, title, department, account_id FROM Contacts LIMIT 1000;"
contacts = await vtiger.query(query)
logger.info(f"📥 Fetched {len(contacts)} contacts from vTiger")