A Odoo API client enabling Go programs to interact with Odoo in a simple and uniform way.
Release v0.0.1 (released on 26-07-2017).
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.
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.
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)
}
- Tests
- New Odoo API functions (ex: report printing)
- If you have an issue, please report it on the issue tracker
Antoine Huret ([email protected])