Skip to content

Commit 69990cb

Browse files
committed
fix(api): add more Odoo vendor query strategies v2.1.17
1 parent ecddf2b commit 69990cb

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

api/server.ts

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "blue-plm",
3-
"version": "2.1.16",
3+
"version": "2.1.17",
44
"description": "Product Lifecycle Management for engineering teams",
55
"main": "dist-electron/main.js",
66
"scripts": {

0 commit comments

Comments
 (0)