It is available on github, as a ruby gem, and can be included in the ruby class of your choice ( as a Rails model for example ).
It still an early version, but is usable in production.
Why Bintje ?
So why it is named Bintje ? Because it is part of a bigger piece of architecture called "Barakafrites" which in french means this :
Yes, they sell "french fries".
Bintje is potato variety used for french fries (And have it's own dedicated character).
Now you clearly understand why this project is called Bintje ... ( Just kidding ... )
Using Bintje
First it needs OpenERP / OpenObject backend address, an example setup :
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## It is up to you to define how you load config ( initilizer , config object, yaml file ... ) | |
## Bintje supports the options below ( but common and object are pointless now ... ) | |
OpenObject.host = 'localhost' | |
OpenObject.port = '8069' | |
OpenObject.common = '/xmlrpc/common' | |
OpenObject.object = '/xmlrpc/object' | |
OpenObject.logger = Logger.new(File::NULL) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class OpenObject::Partner | |
include OpenObjectModel | |
set_open_object_model 'res.partner' | |
## Where user context is the trinity : {uid: Int , dbname: String , pwd: String} | |
def my_custom_method(user_context) | |
OpenObject.rescue_xmlrpc_fault do | |
response = self.class.connection(user_context).execute(self.class.open_object_model, 'remoteOpenObjectMethod', self.id.to_i) | |
OpenObject::BackendResponse.new(success: true, content: response) | |
end | |
end | |
end |
You first need to include the module, once done your class will inherit module's class methods ( see documentation ), and gain the `open_object_model` class variable which is inferred from your ruby object name, but can be overriden as you can see in this gist above. And now you can query the OpenObject Backend and obtain a BackendResponse Object ( see documentation )
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Search for a partner: | |
resps = Partner.search({uid: 3, dbname: "example", pwd: "example_pwd"}, [["name", "=", "The World Compagny"] | |
if resps.success | |
puts resps.content | |
else puts resps.errors | |
## Create a partner ... | |
Partner.create({uid: 3, dbname: "example", pwd: "example_pwd"},{name:"Through Voidness ..."}) | |
No comments:
Post a Comment