Package Exports
- nestjs-odoo
- nestjs-odoo/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (nestjs-odoo) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
NestJS Odoo Integration
A NestJS module for integrating with Odoo using XML-RPC.
Installation
npm install nestjs-odoo
Usage
// app.module.ts
import { Module } from '@nestjs/common';
import { OdooModule } from 'nestjs-odoo';
@Module({
imports: [
OdooModule.forRoot({
url: 'your-odoo-server.com',
port: 8069,
db: 'your-database',
username: 'your-username',
password: 'your-password',
}),
],
})
export class AppModule {}
// your.service.ts
import { Injectable } from '@nestjs/common';
import { OdooService } from 'nestjs-odoo';
@Injectable()
export class YourService {
constructor(private readonly odooService: OdooService) {}
async getPartners() {
const partners = await this.odooService.searchRead(
'res.partner',
[['is_company', '=', true]],
['name', 'email', 'phone'],
);
return partners;
}
}
Available Methods
authenticate()
: Authenticate with Odoo serversearch()
: Search for recordsread()
: Read record detailssearchRead()
: Combine search and read operationscreate()
: Create new recordswrite()
: Update existing recordsunlink()
: Delete records
Configuration
Basic Configuration
Use forRoot()
to provide static configuration:
OdooModule.forRoot({
url: 'your-odoo-server.com',
port: 8069,
db: 'your-database',
username: 'your-username',
password: 'your-password',
});
Async Configuration
Use forRootAsync()
for dynamic configuration:
OdooModule.forRootAsync({
inject: [ConfigService],
useFactory: (configService: ConfigService) => ({
url: configService.get('ODOO_URL'),
port: configService.get('ODOO_PORT'),
db: configService.get('ODOO_DB'),
username: configService.get('ODOO_USERNAME'),
password: configService.get('ODOO_PASSWORD'),
}),
});
API Reference
OdooService Methods
authenticate()
Authenticates with the Odoo server and returns a user ID.
search(model: string, domain: any[], options: any = {})
Searches for records matching the given domain.
read(model: string, ids: number[], fields: string[] = [])
Reads the specified fields of records with the given IDs.
searchRead(model: string, domain: any[] = [], fields: string[] = [], options: any = {})
Combines search and read operations in a single call.
create(model: string, values: any)
Creates a new record with the given values.
write(model: string, id: number, values: any)
Updates an existing record with the given values.
unlink(model: string, id: number)
Deletes the specified record.
License
MIT