-
Notifications
You must be signed in to change notification settings - Fork 59
Object Service API
Raphaël Valyi edited this page Apr 24, 2014
·
6 revisions
TODO
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
ResPartner.find(:all, :domain=>[['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],'|',['name', '=', 'PC1'],['name','=','PC2']])
(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
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 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.