Skip to content

mickymiek/go-odoo

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-odoo

A Odoo API client enabling Go programs to interact with Odoo in a simple and uniform way.

NOTE

Release v0.0.1 (released on 26-07-2017).

Coverage

This API client package covers all basic functions from the odoo API. This include all calls to the following services :

  • Login
  • Create
  • Update
  • Delete
  • Search
  • Read
  • SearchRead
  • SearchCount
  • DoRequest

Services listed above are basic low-level functions from Odoo API, there accessible by any client.

There also are high-level functions based on these low-level functions. Each model has its own functions. Actually we got:

  • GetIdsByName
  • GetByIds
  • GetByName
  • GetAll
  • Create
  • Update
  • Delete

All models are automatically generated by the model2types.py and models.csv files who take datas and retranscribe into .go files. All api functions are automatically generated by the model2api.py and models.csv files.

Usage

import "github.com/skilld-labs/go-odoo/api"

You have to construct a new client.

	c, err := api.NewClient("http://localhost:8069", nil)
	if err != nil {
		fmt.Println(err.Error())
	}
	err = c.Login("dbName", "Admin", "password")
	if err != nil {
		fmt.Println(err.Error())
	}

If you want to generate your own model, you have to check if it is into the 'models.csv' file or add it. Then, you generate all models with the python command

python model2types.py

Recover your .go file in the 'go-types' folder and add it into the 'types' folder.

Examples

This is an example of how to create a new sale order :

package main

import (
	"fmt"

	"github.com/skilld-labs/go-odoo/api"
)

func main() {
	c, err := api.NewClient("http://localhost:8069", nil)
	if err != nil {
		fmt.Println(err.Error())
	}
	err = c.Login("dbName", "admin", "password")
	if err != nil {
		return err
	}
	//get the sale order service
	s := api.NewSaleOrderService(c)
	//call the function GetAll() linked to the sale order service
	so, err := s.GetAll()
	if err != nil {
		fmt.Println(err.Error())
	}
	fmt.Println(so)
}

ToDo

  • Tests
  • New Odoo API functions (ex: report printing)

Issues

Author

Antoine Huret ([email protected])

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 99.6%
  • Python 0.4%