astronaut1712 / angular2-odoo-jsonrpc

OdooRPC for angular2
21 stars 24 forks source link

angular2-odoorpc

OdooRPC for angular2

Migrate from https://github.com/akretion/angular-odoo/blob/master/src/components/odoo/jsonRpc-service.js

Installation

npm install --save angular2-odoo-jsonrpc

Functions list

How to use

Import OdooRPCService into component

import { Component } from '@angular/core';
import { OdooRPCService } from 'angular2-odoo-jsonrpc';

Add provider in app component

@Component({
    ...
    providers: [OdooRPCService]
})

Initialize configuration in constructor of component


export class OdooClientExampleComponent {

    constructor(odooRPC: OdooRPCService){
        this.odooRPC.init({
            odoo_server: "https://odoo-server-example",
            http_auth: "username:password" // optional
        });
        this.odooRPC.login('db_example', 'username', 'password').then(res => {
            console.log('login success');
        }).catch( err => {
            console.error('login failed', err);
        })
    }

    ...

}