@@ -670,23 +670,23 @@ async function fetchOdooSuppliers(
670670 debug . supplier_ids_type = `supplier_rank:error:${ e } `
671671 }
672672
673- // Strategy 2: If no results, try 'supplier' boolean (older Odoo )
673+ // Strategy 2: Partners with vendor payment terms (indicates vendor setup )
674674 if ( ! isValidIdArray ( supplierIds ) ) {
675675 try {
676676 supplierIds = await odooXmlRpc ( normalizedUrl , 'object' , 'execute_kw' , [
677677 database , uid , apiKey ,
678678 'res.partner' , 'search' ,
679- [ [ [ 'supplier ' , '=' , true ] ] ] ,
679+ [ [ [ 'property_supplier_payment_term_id ' , '! =' , false ] ] ] ,
680680 { limit : 5000 }
681681 ] )
682- queryUsed = 'supplier_boolean '
683- debug . supplier_ids_type += ` → supplier_boolean :${ typeof supplierIds } ${ Array . isArray ( supplierIds ) ? `[${ supplierIds . length } ]` : '' } `
682+ queryUsed = 'payment_terms '
683+ debug . supplier_ids_type += ` → payment_terms :${ typeof supplierIds } ${ Array . isArray ( supplierIds ) ? `[${ supplierIds . length } ]` : '' } `
684684 } catch {
685- debug . supplier_ids_type += ' → supplier_boolean:field_not_found '
685+ debug . supplier_ids_type += ' → payment_terms:field_error '
686686 }
687687 }
688688
689- // Strategy 3: If still no results, get all companies (broad search )
689+ // Strategy 3: All companies (broad - will include customers too )
690690 if ( ! isValidIdArray ( supplierIds ) ) {
691691 try {
692692 supplierIds = await odooXmlRpc ( normalizedUrl , 'object' , 'execute_kw' , [
@@ -702,6 +702,22 @@ async function fetchOdooSuppliers(
702702 }
703703 }
704704
705+ // Strategy 4: Last resort - ALL active partners
706+ if ( ! isValidIdArray ( supplierIds ) ) {
707+ try {
708+ supplierIds = await odooXmlRpc ( normalizedUrl , 'object' , 'execute_kw' , [
709+ database , uid , apiKey ,
710+ 'res.partner' , 'search' ,
711+ [ [ [ 'active' , '=' , true ] ] ] ,
712+ { limit : 1000 } // Smaller limit for broad query
713+ ] )
714+ queryUsed = 'all_partners'
715+ debug . supplier_ids_type += ` → all_partners:${ typeof supplierIds } ${ Array . isArray ( supplierIds ) ? `[${ supplierIds . length } ]` : '' } `
716+ } catch ( e ) {
717+ debug . supplier_ids_type += ` → all_partners:error:${ e } `
718+ }
719+ }
720+
705721 // debug.supplier_ids_type is set in the query strategies above
706722
707723 // Ensure supplierIds is an array
0 commit comments