feat: Convert all app files to JS
This commit is contained in:
98
packages/backend/src/apps/odoo/actions/create-lead/index.js
Normal file
98
packages/backend/src/apps/odoo/actions/create-lead/index.js
Normal file
@@ -0,0 +1,98 @@
|
||||
import defineAction from '../../../../helpers/define-action.js';
|
||||
import { authenticate, asyncMethodCall } from '../../common/xmlrpc-client.js';
|
||||
|
||||
export default defineAction({
|
||||
name: 'Create Lead',
|
||||
key: 'createLead',
|
||||
description: '',
|
||||
arguments: [
|
||||
{
|
||||
label: 'Name',
|
||||
key: 'name',
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'Lead name',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Type',
|
||||
key: 'type',
|
||||
type: 'dropdown',
|
||||
required: true,
|
||||
variables: true,
|
||||
options: [
|
||||
{
|
||||
label: 'Lead',
|
||||
value: 'lead',
|
||||
},
|
||||
{
|
||||
label: 'Opportunity',
|
||||
value: 'opportunity',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'Email',
|
||||
key: 'email',
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: 'Email of lead contact',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Contact Name',
|
||||
key: 'contactName',
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: 'Name of lead contact',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Phone Number',
|
||||
key: 'phoneNumber',
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: 'Phone number of lead contact',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Mobile Number',
|
||||
key: 'mobileNumber',
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: 'Mobile number of lead contact',
|
||||
variables: true,
|
||||
},
|
||||
],
|
||||
|
||||
async run($) {
|
||||
const uid = await authenticate($);
|
||||
const id = await asyncMethodCall($, {
|
||||
method: 'execute_kw',
|
||||
params: [
|
||||
$.auth.data.databaseName,
|
||||
uid,
|
||||
$.auth.data.apiKey,
|
||||
'crm.lead',
|
||||
'create',
|
||||
[
|
||||
{
|
||||
name: $.step.parameters.name,
|
||||
type: $.step.parameters.type,
|
||||
email_from: $.step.parameters.email,
|
||||
contact_name: $.step.parameters.contactName,
|
||||
phone: $.step.parameters.phoneNumber,
|
||||
mobile: $.step.parameters.mobileNumber,
|
||||
},
|
||||
],
|
||||
],
|
||||
path: 'object',
|
||||
});
|
||||
|
||||
$.setActionItem({
|
||||
raw: {
|
||||
id: id,
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
@@ -1,103 +0,0 @@
|
||||
import defineAction from '../../../../helpers/define-action';
|
||||
import { authenticate, asyncMethodCall } from '../../common/xmlrpc-client';
|
||||
|
||||
export default defineAction({
|
||||
name: 'Create Lead',
|
||||
key: 'createLead',
|
||||
description: '',
|
||||
arguments: [
|
||||
{
|
||||
label: 'Name',
|
||||
key: 'name',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
description: 'Lead name',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Type',
|
||||
key: 'type',
|
||||
type: 'dropdown' as const,
|
||||
required: true,
|
||||
variables: true,
|
||||
options: [
|
||||
{
|
||||
label: 'Lead',
|
||||
value: 'lead'
|
||||
},
|
||||
{
|
||||
label: 'Opportunity',
|
||||
value: 'opportunity'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
label: "Email",
|
||||
key: 'email',
|
||||
type: 'string' as const,
|
||||
required: false,
|
||||
description: 'Email of lead contact',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: "Contact Name",
|
||||
key: 'contactName',
|
||||
type: 'string' as const,
|
||||
required: false,
|
||||
description: 'Name of lead contact',
|
||||
variables: true
|
||||
},
|
||||
{
|
||||
label: 'Phone Number',
|
||||
key: 'phoneNumber',
|
||||
type: 'string' as const,
|
||||
required: false,
|
||||
description: 'Phone number of lead contact',
|
||||
variables: true
|
||||
},
|
||||
{
|
||||
label: 'Mobile Number',
|
||||
key: 'mobileNumber',
|
||||
type: 'string' as const,
|
||||
required: false,
|
||||
description: 'Mobile number of lead contact',
|
||||
variables: true
|
||||
}
|
||||
],
|
||||
|
||||
async run($) {
|
||||
const uid = await authenticate($);
|
||||
const id = await asyncMethodCall(
|
||||
$,
|
||||
{
|
||||
method: 'execute_kw',
|
||||
params: [
|
||||
$.auth.data.databaseName,
|
||||
uid,
|
||||
$.auth.data.apiKey,
|
||||
'crm.lead',
|
||||
'create',
|
||||
[
|
||||
{
|
||||
name: $.step.parameters.name,
|
||||
type: $.step.parameters.type,
|
||||
email_from: $.step.parameters.email,
|
||||
contact_name: $.step.parameters.contactName,
|
||||
phone: $.step.parameters.phoneNumber,
|
||||
mobile: $.step.parameters.mobileNumber
|
||||
}
|
||||
]
|
||||
],
|
||||
path: 'object',
|
||||
},
|
||||
);
|
||||
|
||||
$.setActionItem(
|
||||
{
|
||||
raw: {
|
||||
id: id
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
});
|
3
packages/backend/src/apps/odoo/actions/index.js
Normal file
3
packages/backend/src/apps/odoo/actions/index.js
Normal file
@@ -0,0 +1,3 @@
|
||||
import createLead from './create-lead/index.js';
|
||||
|
||||
export default [createLead];
|
@@ -1,3 +0,0 @@
|
||||
import createLead from './create-lead';
|
||||
|
||||
export default [createLead];
|
Reference in New Issue
Block a user