Object Service API - akretion/ooor GitHub Wiki
Search
TODO
Finders
Basic finders
ProductProduct.find 1
#=> <ProductProduct id: 1 ...
ProductProduct.find [1,2]
#=> [<ProductProduct id: 1 ..., <ProductProduct id: 2
ProductProduct.find [1]
ProductProduct.find :all
ProductProduct.find :last
ProductProduct.find :first
Finders with support for OpenERP domains
ResPartner.find(:all, :domain=>['supplier', '=', 1],['active','=',1](/akretion/ooor/wiki/'supplier',-'=',-1],['active','=',1))
#More subtle now, remember OpenERP 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],'](/akretion/ooor/wiki/',['name',-'=',-'PC1'],['name','=','PC2'))
Relational Algebra emulation
(see http://www.slideshare.net/brynary/arel-ruby-relational-algebra)
ResCountry.first
ResCountry.last
ResCountry.all
ResCountry.where(:code => 'FR').first
ResCountry.offset(10).limit(2).all
ResCountry.context(:lang => 'pt_BR').first
Persistence
Ooor tries to implement the common part between ActiveRecord and Mongoid API's, including:
- create
- create!
- save
- save!
- update_attributes
- update_attributes!
- update_attribute
- delete
- destroy
Validations
Validations will happen anyhow in OpenERP. But if you want to add extra validations in your Ruby layer, you can. Ooor ActiveModel::Validations to supply the basic validation plus an additional associated and uniqueness validator. Refer to ActiveModel::Validations documentation for more information.