• Stars
    star
    190
  • Rank 203,739 (Top 5 %)
  • Language
    Ruby
  • License
    MIT License
  • Created about 15 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Odoo Ruby JSON client. Emulates ActiveRecord enough (as much as Mongoid; Implements ActiveModel) to make Rails development with an Odoo datastore straightforward

Build Status Code Climate Coverage Status Gem Version Dependency Status

OOOR by Akretion

Why use Ooor?

  • Ooor is an administration Swiss Army knife in an interactive Ruby session. You connect remotely to any running Odoo instance without stopping it, without compromising its security. It has tab auto-completion and object introspection features. You can script anything you would do in the web interface or in an Odoo module with the same level of query optimization.
  • Ooor is the basis for unleashed web development. It is Rack based and inject proxies to Odoo entities in your Rack env just like you use them in your env registry in Odoo modules. You use it in popular Ruby web frameworks such as Sinatra or Rails.

Odoo is all the rage for efficiently building an ERP back-office, but sometimes you want freedom and scalablity for your web front ends. Ooor enables you to model your web app using standard web frameworks like Rails while using Odoo as the persistence layer - without data duplication or synchronization/mapping logic - and reusing the Odoo business logic. Ooor even has an optionnal Rack filter that enables you to proxy some Odoo applications of your choice (say the shopping cart for instance) and share the HTTP session with it.

Because Ooor is ActiveModel based and emulates the ActiveRecord API well enough, it just works with popular Ruby gems such as Devise for authentication, will_paginate for pagination, SimpleForm, Cocoon for nested forms...

Ooor is also a lot more advanced than its Python clones: it is very carefuly designed to save Odoo requests. It can avoid the N+1 queries and also works smartly with the Rails cache so that the meta-data used to define the Odoo proxies can be cached shared between concurrent Rails workers without the need to hit Odoo again with requests such as fields_get.

Related projects - a full web stack!

  • Ooorest, Ooor is the Model layer of MVC. Ooorest is the Controller layer, enforcing a clean Railish REST API and offering handy helper to use Odoo in your Rails application.
  • Aktooor, Aktooor is the missing View layer of MVC. It's based on SimpleForm, that is a clean minimalist framework that extend Rails form framework over Twitter Bootstrap
  • Erpify, Erpify is Odoo inside the Liquid non evaling language, that is the templating language of Shopify or LocomotiveCMS for instance.
  • Locomotive-erpify, Erpify for LocomotiveCMS, both the engine and the Wagon local editor
  • Solarize, pulling data from Odoo relational database may not scale to your need. No problem with Solarize: you can index your OpenERP data with the Solerp OpenERP module, then search it using SolR API and even load it from SolR without even hitting OpenERP!
  • TerminatOOOR, a Pentaho ETL Kettle plugin allowing to push/pull data into/from Odoo with an incomparable flexibility and yet benefit all standard ETL features, including the AgileBI OLAP business intelligence plugin.

How?

Odoo is a Python based open source ERP. But every Odoo business method is actually exposed as a JSON-RPC webservice (SOA orientation, close to being RESTful). Ooor doesn't connect to the Odoo database directly, Instead it uses the Odoo JSON-RPC API so it fully enforces Odoo security model and business logic.

Ooor is around 2000 lines of code and has a test coverage over 93%. The API it exposes is not invented but it is the one of Rails: it is modeled after Rails ActiveModel, ActiveResource and ActiveRecord layers.

More specifically, an Odoo Ooor proxy implements the ActiveModel API. Instead of depending on ActiveResource which is actually a bit different (not multi-tenant, little access right management), we copied a tiny subset of it in the mini_active_resource.rb file and Odoo proxies include this module. Finally Ooor emulates the ActiveRecord API wherever possible delegating its requests to Odoo using Odoo domain S expressions instead of SQL. The ActiveRecord API emulation is actually pretty good: think Ooor looks more like ActiveRecord than Mongoid; it has associations, surface ARel API, Reflection API, can be paginated via Kaminary, can be integrated with SimpleForm or Cocoon seamlessly...

Ooor features several session modes: in the default IRB console usage it uses a global login scheme and generate constants for your OpenERP proxies, such as ProductProduct for the product.product OpenERP object much like Rails ActiveRecord. In web mode instead, you can have several sessions and do session['product.product'] to get a proxy to the Product object matching your current session credentials, chosen database and OpenERP url (yes Ooor is not only multi-database like OpenEP, it's in fact multi-OpenERP!)

Installation

$ gem install ooor

Warning Ooor has been ureleased for several months, don't hesitate to run the git version instead

Trying it simply

Once you installed the OOOR gem, you get a new OOOR command line. Basic usage is:

$ ooor username:password@host:port/database

This will bring you in a standard IRB interpreter with an ooor client already connected to your Odoo server so you can start playing with it.

Standalone (J)Ruby application:

Let's test ooor in an irb console (irb command):

require 'rubygems'
require 'ooor'
Ooor.new(:url => 'http://localhost:8069/xmlrpc', :database => 'mybase', :username => 'admin', :password => 'admin')

This should load all your Odoo models into Ruby proxy Activeresource objects. Of course there are option to load only some models. Let's try to retrieve the user with id 1:

ResUsers.find(1)

(in case you have an error like "no such file to load -- net/https", then on Debian/Ubuntu, you might need to do before: apt-get install libopenssl-ruby)

(J)Ruby on Rails application:

Please read details https://github.com/rvalyi/ooor/wiki/(J)Ruby-on-Rails-application

API usage

Note: Ruby proxy objects are named after Odoo models in but removing the '.' and using CamelCase. (we remind you that Odoo tables are also named after Odoo models but replacing the '.' by '_'.)

Basic finders:

ProductProduct.find(1)
ProductProduct.find([1,2])
ProductProduct.find([1])
ProductProduct.find(:all)
ProductProduct.find(:last)

Odoo domain support (same as Odoo):

ResPartner.find(:all, :domain=>[['supplier', '=', 1],['active','=',1]])
#More subtle now, remember Odoo use a kind of inverse polish notation for complex domains,
#here we look for a product in category 1 AND which name is either 'PC1' OR 'PC2':
ProductProduct.find(:all, :domain=>[['categ_id','=',1],'|',['name', '=', 'PC1'],['name','=','PC2']])

Odoo context support (same as Odoo):

ProductProduct.find(1, :context => {:my_key => 'value'})

Request params or ActiveResource equivalence of Odoo domain (but degraded as only the = operator is supported, else use domain):

ResPartner.find(:all, :params => {:supplier => true})

Odoo search method:

ResPartner.search([['name', 'ilike', 'a']], 0, 2)

Arguments are: domain, offset=0, limit=false, order=false, context={}, count=false

Relations (many2one, one2many, many2many) support:

SaleOrder.find(1).order_line #one2many relation
p = ProductProduct.find(1)
p.product_tmpl_id #many2one relation
p.taxes_id #automagically reads man2many relation inherited via the product_tmpl_id inheritance relation
p.taxes_id = [1,2] #save a many2many relation, notice how we bypass the awkward Odoo syntax for many2many (would require [6,0, [1,2]]) ,
p.save #assigns taxes with id 1 and 2 as sale taxes,
see [the official Odoo documentation](http://doc.openerp.com/developer/5_18_upgrading_server/19_1_upgrading_server.html?highlight=many2many)```


Inherited relations support:

```ruby
ProductProduct.find(1).categ_id #where categ_id is inherited from the ProductTemplate

Please notice that loaded relations are cached (to avoid hitting Odoo over and over) until the root object is reloaded (after save/update for instance).

Load only specific fields support (faster than loading all fields):

ProductProduct.find(1, :fields=>["state", "id"])
ProductProduct.find(:all, :fields=>["state", "id"])
ProductProduct.find([1,2], :fields=>["state", "id"])
ProductProduct.find(:all, :fields=>["state", "id"])
even in relations:
SaleOrder.find(1).order_line(:fields => ["state"])

Create:

pc = ProductCategory.new(:name => 'Categ From Rails!')
# <ProductCategory:0xb702c42c @prefix_options={}, @attributes={"name"=>"Categ From Rails!"}>
pc.create
pc.id
# $ => 14

Update:

pc.name = "A new name"
pc.save

Copy:

copied_object = pc.copy({:categ_id => 2})  #first optionnal arg is new default values, second is context

Delete:

pc.destroy

Call workflow:

s = SaleOrder.find(2)
s.wkf_action('cancel')
s.state
# => 'cancel'

On Change methods:

Note: currently OOOR doesn't deal with the View layer, or has a very limited support for forms for the wizards. So, it's not possible so far for OOOR to know an on_change signature. Because of this, the on_change syntax is bit awkward as you will see (fortunately OpenERP SA announced they will fix that on_change API in subsequent v6 OpenERP releases): you need to explicitely tell the on_change name, the parameter name that changed, the new value and finally enforce the on_change syntax (looking at the OpenERP model code or view or XML/RPC logs will help you to find out). But ultimately it works:

l = SaleOrderLine.new
l.on_change('product_id_change', :product_id, 20, 1, 20, 1, false, 1, false, false, 7, 'en_US', true, false, false, false)
# => #<SaleOrderLine:0x7f76118b4348 @prefix_options={}, @relations={"product_uos"=>false, "product_id"=>20, "product_uom"=>1, "tax_id"=>[]}, @loaded_relations={}, @attributes={"name"=>"[TOW1] ATX Mid-size Tower", "product_uos_qty"=>1, "delay"=>1.0, "price_unit"=>37.5, "type"=>"make_to_stock", "th_weight"=>0}>

Notice that it reloads the Objects attrs and print warning message accordingly

On the fly one2many object graph update/creation:

Just like the OpenERP GTK client (and unlike the web client), in OOOR you can pass create/update one2many relation in place directly. For instance:

so = SaleOrder.new
so.on_change('onchange_partner_id', :partner_id, 1, 1, false) #auto-complete the address and other data based on the partner
so.order_line = [SaleOrderLine.new(:name => 'sl1', :product_id => 1, :price_unit => 42, :product_uom => 1)] #create one order line
so.save
so.amount_total
# => 42.0

Call aribtrary method:

$ use static ObjectClass.rpc_execute_with_all method
$ or object.call(method_name, args*) #were args is an aribtrary list of arguments

Class methods from are osv.py/orm.py proxied to OpenERP directly (as the web client does):

ResPartner.name_search('ax', [], 'ilike', {})
ProductProduct.fields_view_get(132, 'tree', {})

Call old style wizards (OpenERP v5):

inv = AccountInvoice.find(4)
# in case the inv.state is 'draft', do inv.wkf_action('invoice_open')
wizard = inv.old_wizard_step('account.invoice.pay') #tip: you can inspect the wizard fields, arch and datas
wizard.reconcile({:journal_id => 6, :name =>"from_rails"}) #if you want to pay all; will give you a reloaded invoice
inv.state
# => "paid"
# or if you want a payment with a write off:
wizard.writeoff_check({"amount" => 12, "journal_id" => 6, "name" =>'from_rails'}) #use the button name as the wizard method
wizard.reconcile({required missing write off fields...}) #will give you a reloaded invoice because state is 'end'
# TODO test and document new osv_memory wizards API

Absolute OpenERP ids aka ir_model_data:

just like Rails fixtures, OpenERP supports absolute ids for its records, especially those imported from XML or CSV. We are here speaking about the string id of the XML or CSV records, eventually prefixed by the module name. Using those ids rather than the SQL ids is a good idea to avoid relying on a particular installation. In OOOR, you can both retrieve one or several records using those ids, like for instance:

ProductCategory.find('product.product_category_3')

Notice that the 'product.' module prefix is optional here but important if you have similar ids in different module scopes. You can also create a resource and it's ir_model_data record alltogether using the ir_mode_data_id param:

ProductCategory.create(:name => 'rails_categ', :ir_model_data_id =>['product', 'categ_x']) #1st tab element is the module, 2nd the id in the module

Obtain report binary data:

To obtain the binary data of an object report simply use the function get_report_data(report_name). This function returns a list that contains the binary data encoded in base64 and a string with the file format. Example:

inv = AccountInvoice.find(3)
report = inv.get_report_data('account.invoice') #account.invoice is the service name defined in Invoices report
# Save the report to a file
# report[1] contains the file extension and report[0] contains the binary data of the report encoded in base64
File.open("invoice_report.#{report[1]}", "w") {|f| f.write(Base64.decode64(report[0]))}

Change logged user:

An Ooor client can have a global user logged in, to change it:

Ooor.global_login('demo', 'demo')
s = SaleOrder.find(2)
# => 'Access denied error'

Instead, every Ooor business objects can also belong to some specific user. To achieve that, generate your object passing proper :user_id and :password parameters inside the context of the method creating the object (typically a find). Notice that methods invoked on an objet use the same credentials as the business objects. Objects generated by this object (by a call to an association for instance) will also have the same credentials.

p = ProductProduct.find(1, :context => {:user_id=>3, :password=>'test'})

This is tipycally the system you will use in a Ruby (Rails or not) web application.

Change log level:

By default the log level is very verbose (debug level) to help newcomers to jumpstart. However you might want to change that. 2 solutions:

Ooor.logger.level = 1 #available levels are those of the standard Ruby Logger class: 0 debug, 1 info, 2 error

In the config yaml file or hash, set the :log_level parameter

Drawing OpenERP UML diagrams with OOOR

Finger in the nose multi-OpenERP instances migration/management with OOOR

Detailed API in the automated test suite

OOOR ships with an RSpec automated unit test suite to avoid regressions. This is also the place where you can easily read the exact API detail to master every OOOR features. You can read the test suite here: http://github.com/rvalyi/ooor/blob/master/spec/ooor_spec.rb Of course this also shows you can use RSpec to specify and test your OpenERP modules. OOOR is actually used to test OpenERP complex features in a specification language business experts can read and even write! In this case CampToCamp used the famous Cucumber functionnal test suite in the OERPScenario project.

FAQ

Please read the FAQ here

More Repositories

1

odoo-usability

Akretion addons to improve Odoo Community Edition + OCA usability
Python
119
star
2

factur-x

Python lib for Factur-X, the e-invoicing standard for France and Germany
Python
108
star
3

nfelib

nfelib - bindings Python para e ler e gerir XML de NF-e, NFS-e nacional, CT-e, MDF-e, BP-e
Python
97
star
4

pywebdriver

Python Web Services to communicate wih Devices
Python
88
star
5

docky

Docky - Helper for docker-compose mainly used in odoo context
Python
56
star
6

boleto_cnab_api

API server for brcobranca (Brazilian boleto/CNAB electronic payment project)
Ruby
42
star
7

angular-odoo

Call Odoo webservices from AngularJS
JavaScript
41
star
8

odoo-py3o-report-templates

Sample reports (quotation, PO, picking, invoice...) for report_py3o
Python
32
star
9

pypostelium

Python Libraries for Point Of Sale Telium payment terminal
Python
26
star
10

sped-extractor

SPED (Sistema Público de Escrituração Digital) no Odoo ERP (ECD, ECF, EFD ICMS IPI, EFD PIS COFINS)
Python
25
star
11

factur-x-libreoffice-extension

Libreoffice Extension to generate PDF Factur-X invoices with Libreoffice Calc
Python
22
star
12

connector-search-engine

This project is now maintained at the OCA at https://github.com/OCA/search-engine
Python
22
star
13

roulier

API for package delivery
Python
20
star
14

ak-odoo-incubator

Misc Odoo modules maturing before going to a specific repo
HTML
20
star
15

odoo-viewer-groups

Adds viewer security level in Odoo
Python
17
star
16

connector-google-spreadsheet

Data spreadsheet import in Odoo https://www.youtube.com/watch?v=JiW67o4QCVA
Python
17
star
17

ooorest

Odoo On Rails, the REST way! A Restful engine and framework to unleash Odoo in Rails applications...
Ruby
14
star
18

nfselib

bindings Python das NFS-e de 450 cidades (usando xsdata com os XSD's do UNINFE)
Python
12
star
19

vim-odoo-snippets

Vim snippets for Odoo
Vim Snippet
12
star
20

ak

The toolbelt for Odoo
Python
12
star
21

connector-amazon

Amazon Connector for odoo
Python
11
star
22

vertical-olive-mill

Opensource Odoo module to manage an Olive Mill. Sponsored by the Barroux Abbey.
Python
11
star
23

odoo-json-rpc

JavaScript
10
star
24

odoo-mooncard-connector

Connector between Odoo (OpenSource ERP) and Mooncard (new-generation corporate cards)
Python
10
star
25

overdue-reminder

Odoo module to handle invoice overdue reminders
Python
9
star
26

xsdata-odoo

Odoo abstract model generator from xsd schemas using xsdata
Python
9
star
27

pyposdisplay

Python Libraries for Point Of Sale Display
Python
8
star
28

file-exchange

File Exchange
Python
7
star
29

esociallib

biblioteca para ler e gerir documentos de Sistema de Escrituração Digital das Obrigações Fiscais, Previdenciárias e Trabalhistas (eSocial)
Python
7
star
30

odooapps

JavaScript
6
star
31

bank-statement-reconcile-simple

An very simple alternative to OCA/bank-statement-reconcile for odoo
Python
6
star
32

ovh-supplier-invoice

Download OVH invoices as supplier invoices in Odoo via SoAPI. For v10, use the module account_invoice_download_ovh from https://github.com/OCA/edi/pull/30
Python
6
star
33

odoo-elasticapm

Elastic APM integration for Odoo
Python
6
star
34

docker-openupgrade

Basic Docker Images with OpenUpgrade
Dockerfile
6
star
35

ctelib

biblioteca para ler e gerir documentos de Conhecimento de Transporte eletrônico (CT-e)
Python
6
star
36

generateds-odoo

generateDS extension to generate Odoo model mixins from XSD schemas
Python
5
star
37

aktooor

forms to edit Odoo entities in your Ruby web app (based on simple_form)
Ruby
5
star
38

erpify

brings Odoo entitites to your customizable Ruby website via the Liquid non-evaling markup language from Shopify
Ruby
5
star
39

csv2xml4odoo

Odoo csv / xml converter
Python
5
star
40

support

Support module between Akretion and customers
Python
5
star
41

ak-prestashop

Cookbook for installing easily prestashop, do not use it for production environnement, it's just for demo
Ruby
5
star
42

factur-x-validator

Odoo module for Factur-X validation
Python
5
star
43

ak-magento

Chef recipe for install magento and webservice extension needed by MagentoERPconnect
Ruby
4
star
44

odoo-import-helper

Small modules to help on data import in Odoo
Python
4
star
45

account-move-import

Python
4
star
46

laposte_api

Python
4
star
47

odoo-ionic-picker

JavaScript
4
star
48

jenji-connector

Odoo-Jenji connector
Python
4
star
49

openerp-addons

git mirror of https://code.launchpad.net/openobject-addons
Python
4
star
50

astrotrain

A transformer that will convert a Shopify template into a Locomotive one
Python
4
star
51

caisse-ap-ip

Caisse-AP over IP protocol server and client
Python
4
star
52

prodoo

Web app to log in to Odoo, access Manufacturing Orders and manage them
JavaScript
4
star
53

sale-configurator

[WIP] Product Configurator based on configurable option (each option is an other product)
HTML
4
star
54

flaskoo

Basic template for Flask Application connected to Odoo
Python
4
star
55

docker-mailcatcher

Lightweigh version of docker mailcatcher image only 132.6 MB
Shell
3
star
56

payment-gateway

Python
3
star
57

odoo-boleto-cnab

Brazilian Boleto and CNAB implementation for Odoo ERP using the brcobranca gem
Python
3
star
58

sale-import

HTML
3
star
59

voodoo-template

Templates for Voodoo
Python
3
star
60

smsclient

smsclient module from julius
Python
3
star
61

odoo2dev

Make your production odoo db copy dev ready
Python
3
star
62

partner-relation

Manage relations between partners in Odoo
Python
3
star
63

PyRemoteServer

Flask App for starting ssh tunneling between an inacessible server and a support team
Python
3
star
64

logistics-center

Allow to exchange file datas between Odoo ERP and external warehouses
Python
3
star
65

odoo-mail

Python
3
star
66

docky-odoo-brasil

Exemplos Docky para OCA/l10n-brazil e uso do Odoo no Brasil
Python
3
star
67

magento-rma

PHP
3
star
68

odoo-factoring

Accounts Receivable Factoring for Odoo; incubation before targeting OCA inclusion
Python
3
star
69

exodoo

Odoo json datastore for LocomotiveCMS
Ruby
3
star
70

custom-report

This are default custom report
Mako
3
star
71

storage-deprecated-moved-to-oca

Python
3
star
72

mdfelib

biblioteca para ler e gerir Manifesto Eletrônico de Documentos Fiscais brasileiros (MDF-e)
Python
3
star
73

subcontractor

Python
3
star
74

edoc-gen

generateDS helper script for Brazilian electronic documents Python libraries and Odoo ERP modules for NF-e, CC-e, NFS-e, MDF-e, CT-e, EFD-Reinf, e-Social, BP-e...
Shell
3
star
75

brazil-fiscal-client

base SOAP Client for the Brazilian fiscal authority
Python
3
star
76

business_intelligence_fields

Python
3
star
77

bank-statement-import-camt

Import CAMT .052 and .053 XML files in Odoo
Python
2
star
78

mrp_subcontracting-backport

backport of mrp_subcontracting* modules from Odoo CE 13.0 to Odoo 12.0
Python
2
star
79

odoo-vat-prorata

Add support for VAT Pro Rata in Odoo
Python
2
star
80

pos-sale-order

Alternative pos implementation that use sale order
Python
2
star
81

carrier-delivery-colipostefr

ColiPoste : Colissimo / So Colissimo for Odoo ERP
Python
2
star
82

ocb-account-payment

Python
2
star
83

mondialrelay_pyt

Python library for MondialRelay (French carrier)
Python
2
star
84

openerp-web

git mirror of https://code.launchpad.net/openerp-web
JavaScript
2
star
85

ebaypyt

Python Ebay API
Python
2
star
86

procurement-suggest

Python
2
star
87

account-move-base-import

Python
2
star
88

ocb-fiscal-rules

Python
2
star
89

docky-odoo-template

This a project template to use with docky
Jinja
2
star
90

geonames-import-simple

Module base_address_city_geonames_import. No dependency on base_location.
HTML
2
star
91

yousign-connector

Odoo-Yousign connector
Python
2
star
92

docker-odoo-project-prebuild

Prebuilt image for Odoo
Dockerfile
1
star
93

chefdk

Shell
1
star
94

siscomexlib

Biblioteca Python para integração da API do Siscomex
1
star
95

manufacturing

Python
1
star
96

connector-import-data

Python
1
star
97

python-cfonb

Python librairy for reading/writing document enforcing the CFONB norm
Python
1
star
98

odoocker

native and base Python dependencies for Odoo on Docker. Based on Trusty. No Odoo src, no Postgresql, no server CMD
Dockerfile
1
star
99

migrate-to-shopinvader

My name is Noe and I will save all of you !
Python
1
star
100

odoo-module-stats

Python
1
star