From 3dd66785499bf898a67241b9cc74114a90c803c1 Mon Sep 17 00:00:00 2001 From: Felipe Martins Diel Date: Sun, 3 Nov 2024 04:20:17 -0300 Subject: [PATCH 1/4] Add language specification option --- .../nodes-base/nodes/Odoo/GenericFunctions.ts | 31 ++-- packages/nodes-base/nodes/Odoo/Odoo.node.ts | 133 +++++++++++++++++- .../Odoo/descriptions/ContactDescription.ts | 89 ++++++++++++ .../descriptions/CustomResourceDescription.ts | 95 ++++++++++++- .../Odoo/descriptions/NoteDescription.ts | 90 ++++++++++++ .../descriptions/OpportunityDescription.ts | 90 ++++++++++++ 6 files changed, 516 insertions(+), 12 deletions(-) diff --git a/packages/nodes-base/nodes/Odoo/GenericFunctions.ts b/packages/nodes-base/nodes/Odoo/GenericFunctions.ts index 5039fb8941..604d6cf11a 100644 --- a/packages/nodes-base/nodes/Odoo/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Odoo/GenericFunctions.ts @@ -9,7 +9,7 @@ import type { import { NodeApiError, randomInt } from 'n8n-workflow'; const serviceJSONRPC = 'object'; -const methodJSONRPC = 'execute'; +const methodJSONRPC = 'execute_kw'; export const mapOperationToJSONRPC = { create: 'create', @@ -147,7 +147,7 @@ export async function odooGetModelFields( method: 'call', params: { service: serviceJSONRPC, - method: methodJSONRPC, + method: 'execute', args: [ db, userID, @@ -177,6 +177,7 @@ export async function odooCreate( operation: OdooCRUD, url: string, newItem: IDataObject, + context?: IDataObject, ) { try { const body = { @@ -191,7 +192,8 @@ export async function odooCreate( password, mapOdooResources[resource] || resource, mapOperationToJSONRPC[operation], - newItem || {}, + [newItem || {}], + { context: context || {} }, ], }, id: randomInt(100), @@ -214,6 +216,7 @@ export async function odooGet( url: string, itemsID: string, fieldsToReturn?: IDataObject[], + context?: IDataObject, ) { try { if (!/^\d+$/.test(itemsID) || !parseInt(itemsID, 10)) { @@ -235,7 +238,10 @@ export async function odooGet( mapOdooResources[resource] || resource, mapOperationToJSONRPC[operation], itemsID ? [+itemsID] : [], - fieldsToReturn || [], + { + fields: fieldsToReturn || [], + context: context || {}, + } ], }, id: randomInt(100), @@ -259,6 +265,7 @@ export async function odooGetAll( filters?: IOdooFilterOperations, fieldsToReturn?: IDataObject[], limit = 0, + context?: IDataObject, ) { try { const body = { @@ -274,9 +281,12 @@ export async function odooGetAll( mapOdooResources[resource] || resource, mapOperationToJSONRPC[operation], (filters && processFilters(filters)) || [], - fieldsToReturn || [], - 0, // offset - limit, + { + fields: fieldsToReturn || [], + offset: 0, + limit: limit, + context: context || {}, + } ], }, id: randomInt(100), @@ -299,6 +309,7 @@ export async function odooUpdate( url: string, itemsID: string, fieldsToUpdate: IDataObject, + context?: IDataObject, ) { try { if (!Object.keys(fieldsToUpdate).length) { @@ -325,8 +336,8 @@ export async function odooUpdate( password, mapOdooResources[resource] || resource, mapOperationToJSONRPC[operation], - itemsID ? [+itemsID] : [], - fieldsToUpdate, + [itemsID ? [+itemsID] : [], fieldsToUpdate], + { context: context || {} }, ], }, id: randomInt(100), @@ -348,6 +359,7 @@ export async function odooDelete( operation: OdooCRUD, url: string, itemsID: string, + context?: IDataObject, ) { if (!/^\d+$/.test(itemsID) || !parseInt(itemsID, 10)) { throw new NodeApiError(this.getNode(), { @@ -369,6 +381,7 @@ export async function odooDelete( mapOdooResources[resource] || resource, mapOperationToJSONRPC[operation], itemsID ? [+itemsID] : [], + { context: context || {} } ], }, id: randomInt(100), diff --git a/packages/nodes-base/nodes/Odoo/Odoo.node.ts b/packages/nodes-base/nodes/Odoo/Odoo.node.ts index 58472d9340..6879b1c38c 100644 --- a/packages/nodes-base/nodes/Odoo/Odoo.node.ts +++ b/packages/nodes-base/nodes/Odoo/Odoo.node.ts @@ -231,6 +231,36 @@ export class Odoo implements INodeType { return options.sort((a, b) => a.name?.localeCompare(b.name) || 0) as INodePropertyOptions[]; }, + async getSupportedLanguages(this: ILoadOptionsFunctions): Promise { + const credentials = await this.getCredentials('odooApi'); + const url = credentials.url as string; + const username = credentials.username as string; + const password = credentials.password as string; + const db = odooGetDBName(credentials.db as string, url); + const userID = await odooGetUserID.call(this, db, username, password, url); + + const body = { + jsonrpc: '2.0', + method: 'call', + params: { + service: 'object', + method: 'execute', + args: [db, userID, password, 'res.lang', 'search_read', [], ['code', 'name']], + }, + id: randomInt(100), + }; + + const response = (await odooJSONRPCRequest.call(this, body, url)) as IDataObject[]; + + const options = Object.values(response).map(lang => ({ + name: lang.name as string, + value: lang.code as string + })); + + return options.sort((a, b) => + a.name?.localeCompare(b.name) || 0 + ) as INodePropertyOptions[]; + } }, credentialTest: { async odooApiTest( @@ -335,6 +365,10 @@ export class Odoo implements INodeType { name, ...additionalFields, }; + const options = this.getNodeParameter('options', i); + const language = options.language as string; + const context = language ? { lang: language } : {}; + responseData = await odooCreate.call( this, db, @@ -344,11 +378,16 @@ export class Odoo implements INodeType { operation, url, fields, + context, ); } if (operation === 'delete') { const contactId = this.getNodeParameter('contactId', i) as string; + const options = this.getNodeParameter('options', i); + const language = options.language as string; + const context = language ? { lang: language } : {}; + responseData = await odooDelete.call( this, db, @@ -358,6 +397,7 @@ export class Odoo implements INodeType { operation, url, contactId, + context, ); } @@ -365,6 +405,9 @@ export class Odoo implements INodeType { const contactId = this.getNodeParameter('contactId', i) as string; const options = this.getNodeParameter('options', i); const fields = (options.fieldsList as IDataObject[]) || []; + const language = options.language as string; + const context = language ? { lang: language } : {}; + responseData = await odooGet.call( this, db, @@ -375,6 +418,7 @@ export class Odoo implements INodeType { url, contactId, fields, + context, ); } @@ -382,6 +426,9 @@ export class Odoo implements INodeType { const returnAll = this.getNodeParameter('returnAll', i); const options = this.getNodeParameter('options', i); const fields = (options.fieldsList as IDataObject[]) || []; + const language = options.language as string; + const context = language ? { lang: language } : {}; + if (returnAll) { responseData = await odooGetAll.call( this, @@ -393,6 +440,8 @@ export class Odoo implements INodeType { url, undefined, fields, + undefined, + context, ); } else { const limit = this.getNodeParameter('limit', i); @@ -407,6 +456,7 @@ export class Odoo implements INodeType { undefined, // filters, only for custom resource fields, limit, + context, ); } } @@ -426,6 +476,10 @@ export class Odoo implements INodeType { delete updateFields.address; } + const options = this.getNodeParameter('options', i); + const language = options.language as string; + const context = language ? { lang: language } : {}; + responseData = await odooUpdate.call( this, db, @@ -436,6 +490,7 @@ export class Odoo implements INodeType { url, contactId, updateFields, + context, ); } } @@ -444,6 +499,10 @@ export class Odoo implements INodeType { const customResource = this.getNodeParameter('customResource', i) as string; if (operation === 'create') { const fields = this.getNodeParameter('fieldsToCreateOrUpdate', i) as IDataObject; + const options = this.getNodeParameter('options', i); + const language = options.language as string; + const context = language ? { lang: language } : {}; + responseData = await odooCreate.call( this, db, @@ -453,11 +512,16 @@ export class Odoo implements INodeType { operation, url, processNameValueFields(fields), + context, ); } if (operation === 'delete') { const customResourceId = this.getNodeParameter('customResourceId', i) as string; + const options = this.getNodeParameter('options', i); + const language = options.language as string; + const context = language ? { lang: language } : {}; + responseData = await odooDelete.call( this, db, @@ -467,6 +531,7 @@ export class Odoo implements INodeType { operation, url, customResourceId, + context, ); } @@ -474,6 +539,9 @@ export class Odoo implements INodeType { const customResourceId = this.getNodeParameter('customResourceId', i) as string; const options = this.getNodeParameter('options', i); const fields = (options.fieldsList as IDataObject[]) || []; + const language = options.language as string; + const context = language ? { lang: language } : {}; + responseData = await odooGet.call( this, db, @@ -484,14 +552,18 @@ export class Odoo implements INodeType { url, customResourceId, fields, + context, ); } if (operation === 'getAll') { const returnAll = this.getNodeParameter('returnAll', i); const options = this.getNodeParameter('options', i); - const fields = (options.fieldsList as IDataObject[]) || []; const filter = this.getNodeParameter('filterRequest', i) as IOdooFilterOperations; + const fields = (options.fieldsList as IDataObject[]) || []; + const language = options.language as string; + const context = language ? { lang: language } : {}; + if (returnAll) { responseData = await odooGetAll.call( this, @@ -503,6 +575,8 @@ export class Odoo implements INodeType { url, filter, fields, + undefined, + context, ); } else { const limit = this.getNodeParameter('limit', i); @@ -517,6 +591,7 @@ export class Odoo implements INodeType { filter, fields, limit, + context, ); } } @@ -524,6 +599,10 @@ export class Odoo implements INodeType { if (operation === 'update') { const customResourceId = this.getNodeParameter('customResourceId', i) as string; const fields = this.getNodeParameter('fieldsToCreateOrUpdate', i) as IDataObject; + const options = this.getNodeParameter('options', i); + const language = options.language as string; + const context = language ? { lang: language } : {}; + responseData = await odooUpdate.call( this, db, @@ -534,6 +613,7 @@ export class Odoo implements INodeType { url, customResourceId, processNameValueFields(fields), + context, ); } } @@ -545,7 +625,11 @@ export class Odoo implements INodeType { const fields: IDataObject = { memo, // ...additionalFields, - }; + }; + const options = this.getNodeParameter('options', i); + const language = options.language as string; + const context = language ? { lang: language } : {}; + responseData = await odooCreate.call( this, db, @@ -555,11 +639,16 @@ export class Odoo implements INodeType { operation, url, fields, + context, ); } if (operation === 'delete') { const noteId = this.getNodeParameter('noteId', i) as string; + const options = this.getNodeParameter('options', i); + const language = options.language as string; + const context = language ? { lang: language } : {}; + responseData = await odooDelete.call( this, db, @@ -569,6 +658,7 @@ export class Odoo implements INodeType { operation, url, noteId, + context, ); } @@ -576,6 +666,9 @@ export class Odoo implements INodeType { const noteId = this.getNodeParameter('noteId', i) as string; const options = this.getNodeParameter('options', i); const fields = (options.fieldsList as IDataObject[]) || []; + const language = options.language as string; + const context = language ? { lang: language } : {}; + responseData = await odooGet.call( this, db, @@ -586,6 +679,7 @@ export class Odoo implements INodeType { url, noteId, fields, + context, ); } @@ -593,6 +687,9 @@ export class Odoo implements INodeType { const returnAll = this.getNodeParameter('returnAll', i); const options = this.getNodeParameter('options', i); const fields = (options.fieldsList as IDataObject[]) || []; + const language = options.language as string; + const context = language ? { lang: language } : {}; + if (returnAll) { responseData = await odooGetAll.call( this, @@ -604,6 +701,8 @@ export class Odoo implements INodeType { url, undefined, fields, + undefined, + context, ); } else { const limit = this.getNodeParameter('limit', i); @@ -618,6 +717,7 @@ export class Odoo implements INodeType { undefined, // filters, only for custom resource fields, limit, + context, ); } } @@ -628,6 +728,10 @@ export class Odoo implements INodeType { const fields: IDataObject = { memo, }; + const options = this.getNodeParameter('options', i); + const language = options.language as string; + const context = language ? { lang: language } : {}; + responseData = await odooUpdate.call( this, db, @@ -638,6 +742,7 @@ export class Odoo implements INodeType { url, noteId, fields, + context, ); } } @@ -650,6 +755,9 @@ export class Odoo implements INodeType { name, ...additionalFields, }; + const options = this.getNodeParameter('options', i); + const language = options.language as string; + const context = language ? { lang: language } : {}; responseData = await odooCreate.call( this, @@ -660,11 +768,16 @@ export class Odoo implements INodeType { operation, url, fields, + context, ); } if (operation === 'delete') { const opportunityId = this.getNodeParameter('opportunityId', i) as string; + const options = this.getNodeParameter('options', i); + const language = options.language as string; + const context = language ? { lang: language } : {}; + responseData = await odooDelete.call( this, db, @@ -674,6 +787,7 @@ export class Odoo implements INodeType { operation, url, opportunityId, + context, ); } @@ -681,6 +795,9 @@ export class Odoo implements INodeType { const opportunityId = this.getNodeParameter('opportunityId', i) as string; const options = this.getNodeParameter('options', i); const fields = (options.fieldsList as IDataObject[]) || []; + const language = options.language as string; + const context = language ? { lang: language } : {}; + responseData = await odooGet.call( this, db, @@ -691,6 +808,7 @@ export class Odoo implements INodeType { url, opportunityId, fields, + context, ); } @@ -698,6 +816,9 @@ export class Odoo implements INodeType { const returnAll = this.getNodeParameter('returnAll', i); const options = this.getNodeParameter('options', i); const fields = (options.fieldsList as IDataObject[]) || []; + const language = options.language as string; + const context = language ? { lang: language } : {}; + if (returnAll) { responseData = await odooGetAll.call( this, @@ -709,6 +830,8 @@ export class Odoo implements INodeType { url, undefined, fields, + undefined, + context, ); } else { const limit = this.getNodeParameter('limit', i); @@ -723,6 +846,7 @@ export class Odoo implements INodeType { undefined, // filters, only for custom resource fields, limit, + context, ); } } @@ -730,6 +854,10 @@ export class Odoo implements INodeType { if (operation === 'update') { const opportunityId = this.getNodeParameter('opportunityId', i) as string; const updateFields = this.getNodeParameter('updateFields', i); + const options = this.getNodeParameter('options', i); + const language = options.language as string; + const context = language ? { lang: language } : {}; + responseData = await odooUpdate.call( this, db, @@ -740,6 +868,7 @@ export class Odoo implements INodeType { url, opportunityId, updateFields, + context, ); } } diff --git a/packages/nodes-base/nodes/Odoo/descriptions/ContactDescription.ts b/packages/nodes-base/nodes/Odoo/descriptions/ContactDescription.ts index b78287ecaf..4d53ff9af3 100644 --- a/packages/nodes-base/nodes/Odoo/descriptions/ContactDescription.ts +++ b/packages/nodes-base/nodes/Odoo/descriptions/ContactDescription.ts @@ -186,6 +186,31 @@ export const contactDescription: INodeProperties[] = [ }, ], }, + { + displayName: 'Options', + name: 'options', + type: 'collection', + default: {}, + placeholder: 'Add option', + displayOptions: { + show: { + operation: ['create'], + resource: ['contact'], + }, + }, + options: [ + { + displayName: 'Language', + name: 'language', + type: 'options', + description: 'Choose from the list', + default: '', + typeOptions: { + loadOptionsMethod: 'getSupportedLanguages', + }, + }, + ], + }, /* -------------------------------------------------------------------------- */ /* contact:get */ @@ -264,6 +289,16 @@ export const contactDescription: INodeProperties[] = [ loadOptionsMethod: 'getModelFields', }, }, + { + displayName: 'Language', + name: 'language', + type: 'options', + description: 'Choose from the list', + default: '', + typeOptions: { + loadOptionsMethod: 'getSupportedLanguages', + }, + }, ], }, @@ -411,4 +446,58 @@ export const contactDescription: INodeProperties[] = [ }, ], }, + { + displayName: 'Options', + name: 'options', + type: 'collection', + default: {}, + placeholder: 'Add option', + displayOptions: { + show: { + operation: ['update'], + resource: ['contact'], + }, + }, + options: [ + { + displayName: 'Language', + name: 'language', + type: 'options', + description: 'Choose from the list', + default: '', + typeOptions: { + loadOptionsMethod: 'getSupportedLanguages', + }, + }, + ], + }, + + /* -------------------------------------------------------------------------- */ + /* contact:delete */ + /* -------------------------------------------------------------------------- */ + { + displayName: 'Options', + name: 'options', + type: 'collection', + default: {}, + placeholder: 'Add option', + displayOptions: { + show: { + operation: ['delete'], + resource: ['contact'], + }, + }, + options: [ + { + displayName: 'Language', + name: 'language', + type: 'options', + description: 'Choose from the list', + default: '', + typeOptions: { + loadOptionsMethod: 'getSupportedLanguages', + }, + }, + ], + }, ]; diff --git a/packages/nodes-base/nodes/Odoo/descriptions/CustomResourceDescription.ts b/packages/nodes-base/nodes/Odoo/descriptions/CustomResourceDescription.ts index 67552c19d9..dfb544a223 100644 --- a/packages/nodes-base/nodes/Odoo/descriptions/CustomResourceDescription.ts +++ b/packages/nodes-base/nodes/Odoo/descriptions/CustomResourceDescription.ts @@ -109,6 +109,32 @@ export const customResourceDescription: INodeProperties[] = [ }, ], }, + { + displayName: 'Options', + name: 'options', + type: 'collection', + default: {}, + placeholder: 'Add option', + displayOptions: { + show: { + operation: ['create'], + resource: ['custom'], + }, + }, + options: [ + { + displayName: 'Language', + name: 'language', + type: 'options', + description: 'Choose from the list', + default: '', + typeOptions: { + loadOptionsMethod: 'getSupportedLanguages', + loadOptionsDependsOn: ['customResource'], + }, + }, + ], + }, /* -------------------------------------------------------------------------- */ /* custom:get */ @@ -166,7 +192,7 @@ export const customResourceDescription: INodeProperties[] = [ name: 'options', type: 'collection', default: {}, - placeholder: 'Add Field', + placeholder: 'Add option', displayOptions: { show: { operation: ['getAll', 'get'], @@ -186,6 +212,17 @@ export const customResourceDescription: INodeProperties[] = [ loadOptionsDependsOn: ['customResource'], }, }, + { + displayName: 'Language', + name: 'language', + type: 'options', + description: 'Choose from the list', + default: '', + typeOptions: { + loadOptionsMethod: 'getSupportedLanguages', + loadOptionsDependsOn: ['customResource'], + }, + }, ], }, { @@ -282,6 +319,7 @@ export const customResourceDescription: INodeProperties[] = [ }, ], }, + /* -------------------------------------------------------------------------- */ /* custom:update */ /* -------------------------------------------------------------------------- */ @@ -341,4 +379,59 @@ export const customResourceDescription: INodeProperties[] = [ }, ], }, + { + displayName: 'Options', + name: 'options', + type: 'collection', + default: {}, + placeholder: 'Add option', + displayOptions: { + show: { + operation: ['update'], + resource: ['custom'], + }, + }, + options: [ + { + displayName: 'Language', + name: 'language', + type: 'options', + description: 'Choose from the list', + default: '', + typeOptions: { + loadOptionsMethod: 'getSupportedLanguages', + loadOptionsDependsOn: ['customResource'], + }, + }, + ], + }, + + /* -------------------------------------------------------------------------- */ + /* custom:delete */ + /* -------------------------------------------------------------------------- */ + { + displayName: 'Options', + name: 'options', + type: 'collection', + default: {}, + placeholder: 'Add option', + displayOptions: { + show: { + operation: ['delete'], + resource: ['custom'], + }, + }, + options: [ + { + displayName: 'Language', + name: 'language', + type: 'options', + description: 'Choose from the list', + default: '', + typeOptions: { + loadOptionsMethod: 'getSupportedLanguages', + }, + }, + ], + }, ]; diff --git a/packages/nodes-base/nodes/Odoo/descriptions/NoteDescription.ts b/packages/nodes-base/nodes/Odoo/descriptions/NoteDescription.ts index 0cd8f81e7f..1f2ad224e1 100644 --- a/packages/nodes-base/nodes/Odoo/descriptions/NoteDescription.ts +++ b/packages/nodes-base/nodes/Odoo/descriptions/NoteDescription.ts @@ -89,6 +89,31 @@ export const noteDescription: INodeProperties[] = [ // }, // ], // }, + { + displayName: 'Options', + name: 'options', + type: 'collection', + default: {}, + placeholder: 'Add option', + displayOptions: { + show: { + operation: ['create'], + resource: ['note'], + }, + }, + options: [ + { + displayName: 'Language', + name: 'language', + type: 'options', + description: 'Choose from the list', + default: '', + typeOptions: { + loadOptionsMethod: 'getSupportedLanguages', + }, + }, + ], + }, /* -------------------------------------------------------------------------- */ /* note:get */ @@ -166,8 +191,19 @@ export const noteDescription: INodeProperties[] = [ loadOptionsMethod: 'getModelFields', }, }, + { + displayName: 'Language', + name: 'language', + type: 'options', + description: 'Choose from the list', + default: '', + typeOptions: { + loadOptionsMethod: 'getSupportedLanguages', + }, + }, ], }, + /* -------------------------------------------------------------------------- */ /* note:update */ /* -------------------------------------------------------------------------- */ @@ -228,4 +264,58 @@ export const noteDescription: INodeProperties[] = [ // }, // ], // }, + { + displayName: 'Options', + name: 'options', + type: 'collection', + default: {}, + placeholder: 'Add option', + displayOptions: { + show: { + operation: ['update'], + resource: ['note'], + }, + }, + options: [ + { + displayName: 'Language', + name: 'language', + type: 'options', + description: 'Choose from the list', + default: '', + typeOptions: { + loadOptionsMethod: 'getSupportedLanguages', + }, + }, + ], + }, + + /* -------------------------------------------------------------------------- */ + /* note:delete */ + /* -------------------------------------------------------------------------- */ + { + displayName: 'Options', + name: 'options', + type: 'collection', + default: {}, + placeholder: 'Add option', + displayOptions: { + show: { + operation: ['delete'], + resource: ['note'], + }, + }, + options: [ + { + displayName: 'Language', + name: 'language', + type: 'options', + description: 'Choose from the list', + default: '', + typeOptions: { + loadOptionsMethod: 'getSupportedLanguages', + }, + }, + ], + }, ]; diff --git a/packages/nodes-base/nodes/Odoo/descriptions/OpportunityDescription.ts b/packages/nodes-base/nodes/Odoo/descriptions/OpportunityDescription.ts index a6d62f7b13..f8f9073caf 100644 --- a/packages/nodes-base/nodes/Odoo/descriptions/OpportunityDescription.ts +++ b/packages/nodes-base/nodes/Odoo/descriptions/OpportunityDescription.ts @@ -140,6 +140,31 @@ export const opportunityDescription: INodeProperties[] = [ }, ], }, + { + displayName: 'Options', + name: 'options', + type: 'collection', + default: {}, + placeholder: 'Add option', + displayOptions: { + show: { + operation: ['create'], + resource: ['opportunity'], + }, + }, + options: [ + { + displayName: 'Language', + name: 'language', + type: 'options', + description: 'Choose from the list', + default: '', + typeOptions: { + loadOptionsMethod: 'getSupportedLanguages', + }, + }, + ], + }, /* -------------------------------------------------------------------------- */ /* opportunity:get */ @@ -217,8 +242,19 @@ export const opportunityDescription: INodeProperties[] = [ loadOptionsMethod: 'getModelFields', }, }, + { + displayName: 'Language', + name: 'language', + type: 'options', + description: 'Choose from the list', + default: '', + typeOptions: { + loadOptionsMethod: 'getSupportedLanguages', + }, + }, ], }, + /* -------------------------------------------------------------------------- */ /* opportunity:update */ /* -------------------------------------------------------------------------- */ @@ -316,4 +352,58 @@ export const opportunityDescription: INodeProperties[] = [ }, ], }, + { + displayName: 'Options', + name: 'options', + type: 'collection', + default: {}, + placeholder: 'Add option', + displayOptions: { + show: { + operation: ['update'], + resource: ['opportunity'], + }, + }, + options: [ + { + displayName: 'Language', + name: 'language', + type: 'options', + description: 'Choose from the list', + default: '', + typeOptions: { + loadOptionsMethod: 'getSupportedLanguages', + }, + }, + ], + }, + + /* -------------------------------------------------------------------------- */ + /* opportunity:delete */ + /* -------------------------------------------------------------------------- */ + { + displayName: 'Options', + name: 'options', + type: 'collection', + default: {}, + placeholder: 'Add option', + displayOptions: { + show: { + operation: ['delete'], + resource: ['opportunity'], + }, + }, + options: [ + { + displayName: 'Language', + name: 'language', + type: 'options', + description: 'Choose from the list', + default: '', + typeOptions: { + loadOptionsMethod: 'getSupportedLanguages', + }, + }, + ], + }, ]; From d6b6dfc166eb897c314dff8a0e7d015159afcad3 Mon Sep 17 00:00:00 2001 From: Felipe Martins Diel Date: Sun, 3 Nov 2024 04:42:32 -0300 Subject: [PATCH 2/4] Update placeholders --- packages/nodes-base/nodes/Odoo/GenericFunctions.ts | 2 +- .../nodes-base/nodes/Odoo/descriptions/ContactDescription.ts | 2 +- packages/nodes-base/nodes/Odoo/descriptions/NoteDescription.ts | 2 +- .../nodes/Odoo/descriptions/OpportunityDescription.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/nodes-base/nodes/Odoo/GenericFunctions.ts b/packages/nodes-base/nodes/Odoo/GenericFunctions.ts index 604d6cf11a..17fbdc14ca 100644 --- a/packages/nodes-base/nodes/Odoo/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Odoo/GenericFunctions.ts @@ -381,7 +381,7 @@ export async function odooDelete( mapOdooResources[resource] || resource, mapOperationToJSONRPC[operation], itemsID ? [+itemsID] : [], - { context: context || {} } + { context: context || {} }, ], }, id: randomInt(100), diff --git a/packages/nodes-base/nodes/Odoo/descriptions/ContactDescription.ts b/packages/nodes-base/nodes/Odoo/descriptions/ContactDescription.ts index 4d53ff9af3..c03187cd24 100644 --- a/packages/nodes-base/nodes/Odoo/descriptions/ContactDescription.ts +++ b/packages/nodes-base/nodes/Odoo/descriptions/ContactDescription.ts @@ -270,7 +270,7 @@ export const contactDescription: INodeProperties[] = [ name: 'options', type: 'collection', default: {}, - placeholder: 'Add Field', + placeholder: 'Add option', displayOptions: { show: { operation: ['getAll', 'get'], diff --git a/packages/nodes-base/nodes/Odoo/descriptions/NoteDescription.ts b/packages/nodes-base/nodes/Odoo/descriptions/NoteDescription.ts index 1f2ad224e1..e0588318b7 100644 --- a/packages/nodes-base/nodes/Odoo/descriptions/NoteDescription.ts +++ b/packages/nodes-base/nodes/Odoo/descriptions/NoteDescription.ts @@ -172,7 +172,7 @@ export const noteDescription: INodeProperties[] = [ name: 'options', type: 'collection', default: {}, - placeholder: 'Add Field', + placeholder: 'Add option', displayOptions: { show: { operation: ['getAll', 'get'], diff --git a/packages/nodes-base/nodes/Odoo/descriptions/OpportunityDescription.ts b/packages/nodes-base/nodes/Odoo/descriptions/OpportunityDescription.ts index f8f9073caf..77db9831ca 100644 --- a/packages/nodes-base/nodes/Odoo/descriptions/OpportunityDescription.ts +++ b/packages/nodes-base/nodes/Odoo/descriptions/OpportunityDescription.ts @@ -223,7 +223,7 @@ export const opportunityDescription: INodeProperties[] = [ name: 'options', type: 'collection', default: {}, - placeholder: 'Add Field', + placeholder: 'Add option', displayOptions: { show: { operation: ['getAll', 'get'], From 8364f7bc4e12e9faa4f056c306b0240d58562067 Mon Sep 17 00:00:00 2001 From: Felipe Martins Diel Date: Sun, 3 Nov 2024 15:31:45 -0300 Subject: [PATCH 3/4] Remove unused dependencies --- .../nodes/Odoo/descriptions/CustomResourceDescription.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/nodes-base/nodes/Odoo/descriptions/CustomResourceDescription.ts b/packages/nodes-base/nodes/Odoo/descriptions/CustomResourceDescription.ts index dfb544a223..25227537e7 100644 --- a/packages/nodes-base/nodes/Odoo/descriptions/CustomResourceDescription.ts +++ b/packages/nodes-base/nodes/Odoo/descriptions/CustomResourceDescription.ts @@ -130,7 +130,6 @@ export const customResourceDescription: INodeProperties[] = [ default: '', typeOptions: { loadOptionsMethod: 'getSupportedLanguages', - loadOptionsDependsOn: ['customResource'], }, }, ], @@ -220,7 +219,6 @@ export const customResourceDescription: INodeProperties[] = [ default: '', typeOptions: { loadOptionsMethod: 'getSupportedLanguages', - loadOptionsDependsOn: ['customResource'], }, }, ], @@ -400,7 +398,6 @@ export const customResourceDescription: INodeProperties[] = [ default: '', typeOptions: { loadOptionsMethod: 'getSupportedLanguages', - loadOptionsDependsOn: ['customResource'], }, }, ], From 3f94947fc5f7e7578fa9f5f9b3a5a75352895ffa Mon Sep 17 00:00:00 2001 From: Felipe Martins Diel Date: Sat, 16 Nov 2024 21:03:41 -0300 Subject: [PATCH 4/4] Fix getAll() filters --- packages/nodes-base/nodes/Odoo/GenericFunctions.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nodes-base/nodes/Odoo/GenericFunctions.ts b/packages/nodes-base/nodes/Odoo/GenericFunctions.ts index 17fbdc14ca..1e2acfcbe7 100644 --- a/packages/nodes-base/nodes/Odoo/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Odoo/GenericFunctions.ts @@ -280,7 +280,7 @@ export async function odooGetAll( password, mapOdooResources[resource] || resource, mapOperationToJSONRPC[operation], - (filters && processFilters(filters)) || [], + [(filters && processFilters(filters)) || []], { fields: fieldsToReturn || [], offset: 0,