fix(Odoo Node): Model and fields dynamic fetching errors (#13511)

This commit is contained in:
Loan J. 2025-02-28 09:08:01 -05:00 committed by GitHub
parent f5743176e5
commit 294f019414
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -116,19 +116,18 @@ export class Odoo implements INodeType {
const userID = await odooGetUserID.call(this, db, username, password, url);
const response = await odooGetModelFields.call(this, db, userID, password, resource, url);
const options = Object.values(response).map((field) => {
const options = Object.entries(response).map(([key, field]) => {
const optionField = field as { [key: string]: string };
let name = '';
try {
name = capitalCase(optionField.name);
optionField.name = capitalCase(optionField.name);
} catch (error) {
name = optionField.name;
optionField.name = optionField.string;
}
return {
name,
value: optionField.name,
name: optionField.name,
value: key,
// nodelinter-ignore-next-line
description: `name: ${optionField?.name}, type: ${optionField?.type} required: ${optionField?.required}`,
description: `name: ${key}, type: ${optionField?.type} required: ${optionField?.required}`,
};
});
@ -148,15 +147,7 @@ export class Odoo implements INodeType {
params: {
service: 'object',
method: 'execute',
args: [
db,
userID,
password,
'ir.model',
'search_read',
[],
['name', 'model', 'modules'],
],
args: [db, userID, password, 'ir.model', 'search_read', [], ['name', 'model']],
},
id: randomInt(100),
};
@ -167,7 +158,7 @@ export class Odoo implements INodeType {
return {
name: model.name,
value: model.model,
description: `model: ${model.model}<br> modules: ${model.modules}`,
description: `model: ${model.model}`,
};
});
return options as INodePropertyOptions[];