ooor 1.5.2 → 1.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +22 -19
- data/bin/ooor +6 -13
- data/lib/app/models/open_object_resource.rb +3 -3
- data/lib/ooor.rb +6 -6
- data/spec/ooor_spec.rb +6 -0
- metadata +5 -5
data/README.md
CHANGED
@@ -3,16 +3,16 @@ OOOR - OpenObject On Rails
|
|
3
3
|
|
4
4
|
<table>
|
5
5
|
<tr>
|
6
|
-
<td width="159px"><a href="http://github.com/rvalyi/ooor" title="OOOR - OpenObject On
|
6
|
+
<td width="159px"><a href="http://github.com/rvalyi/ooor" title="OOOR - OpenObject On Ruby"><img src="http://akretion.s3.amazonaws.com/assets/ooor_m.jpg" width="159px" height="124px" /></a></td>
|
7
7
|
<td><b>BY</b></td>
|
8
8
|
<td width="320px"><a href="http://www.akretion.com" title="Akretion - open source to spin the world"><img src="http://akretion.s3.amazonaws.com/assets/logo.png" width="320px" height="154px" /></a></td>
|
9
9
|
<td width="285px">
|
10
|
-
OOOR stands for OpenObject On
|
10
|
+
OOOR stands for OpenObject On Ruby. OpenObject is the RAD framework behind OpenERP,
|
11
11
|
the ERP that doesn't hurt, just like Rails is "web development that doesn't hurt".
|
12
|
-
So OOOR exposes seamlessly your
|
12
|
+
So OOOR exposes seamlessly your OpenObject application, to your custom Ruby or Rails application.
|
13
13
|
Needless to say, OOOR doubly doesn't hurt.
|
14
14
|
Furthermore, OOOR only depends on the "activeresource" gem. So it can even be used
|
15
|
-
in any
|
15
|
+
in any Ruby application without Rails. It's also fully JRuby compatible and hence make the bridge between the Python OpenERP and the Java ecosystem.
|
16
16
|
</td>
|
17
17
|
</tr>
|
18
18
|
</table>
|
@@ -21,9 +21,9 @@ in any (J)Ruby application without Rails.
|
|
21
21
|
Why?
|
22
22
|
------------
|
23
23
|
|
24
|
-
OpenERP makes it really straightforward to create
|
24
|
+
OpenERP makes it really straightforward to create custom business applications with:
|
25
25
|
|
26
|
-
* standard ERP business modules (more than
|
26
|
+
* standard ERP business modules (more than 500 modules)
|
27
27
|
* complex relationnal data model, with automated migration and backoffice interfaces
|
28
28
|
* ACID transactions on PostgreSQL
|
29
29
|
* role based
|
@@ -79,16 +79,6 @@ Then we cache that relational model and use it in OpenObjectResource.method_miss
|
|
79
79
|
OOOR also extends ActiveResource a bit with special request parameters (like :domain or :context) that will just map smoothly to the OpenERP native API, see API.
|
80
80
|
|
81
81
|
|
82
|
-
Trying it simply
|
83
|
-
------------
|
84
|
-
|
85
|
-
If you have Java 1.6+ installed, then the easiest way to tryout OOOR might be to download the [TerminatOOOR zip](http://github.com/rvalyi/terminatooor/downloads)
|
86
|
-
and double-click on jruby-ooor.jar or launch it by command line with java -jar jruby-ooor.jar: it will launch an OOOR console with helpful auto-completion (hit 'tab') on OpenERP business objects.
|
87
|
-
|
88
|
-
You can read [an introduction to OOOR on Akretion's blog.](http://www.akretion.com/en/blog/2010/01/18/introducing-ooor---openobject-on-rails-drivingrequesting-your-openerp-became-a-child-play/)
|
89
|
-
|
90
|
-
|
91
|
-
|
92
82
|
Installation
|
93
83
|
------------
|
94
84
|
|
@@ -96,20 +86,33 @@ You can use OOOR in a standalone (J)Ruby application, or in a Rails application,
|
|
96
86
|
For both example we assume that you already started some OpenERP server on localhost, with XML/RPC on port 8069 (default),
|
97
87
|
with a database called 'mybase', with username 'admin' and password 'admin'.
|
98
88
|
|
99
|
-
In all case, you first need to install the ooor gem:
|
89
|
+
In all case, you first need to install Ruby, then the rubygems package manager and finally the ooor gem with:
|
100
90
|
|
101
91
|
$ gem install ooor
|
102
92
|
(the ooor gem is hosted [on gemcutter.org here](http://gemcutter.org/gems/ooor), make sure you have it in your gem source lists, a way is to do >gem tumble)
|
103
93
|
|
104
94
|
|
95
|
+
Trying it simply
|
96
|
+
------------
|
97
|
+
|
98
|
+
Once you installed the OOOR gem, you get a new OOOR command line. Basic usage is:
|
99
|
+
|
100
|
+
$ ooor username.database@host:xmlrpc_port
|
101
|
+
|
102
|
+
This will bring you in a standard IRB interpreter with an OOOR client already connected to your OpenERP server so you can start playing with it.
|
103
|
+
|
104
|
+
|
105
105
|
### Standalone (J)Ruby application:
|
106
106
|
|
107
107
|
Let's test OOOR in an irb console (irb command):
|
108
|
+
|
108
109
|
$ require 'rubygems'
|
109
110
|
$ require 'ooor'
|
110
111
|
$ Ooor.new(:url => 'http://localhost:8069/xmlrpc', :database => 'mybase', :username => 'admin', :password => 'admin')
|
112
|
+
|
111
113
|
This should load all your OpenERP models into Ruby proxy Activeresource objects. Of course there are option to load only some models.
|
112
114
|
Let's try to retrieve the user with id 1:
|
115
|
+
|
113
116
|
$ ResUsers.find(1)
|
114
117
|
|
115
118
|
(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)
|
@@ -124,7 +127,7 @@ API usage
|
|
124
127
|
------------
|
125
128
|
|
126
129
|
Note: Ruby proxies objects are named after OpenERP models in but removing the '.' and using CamelCase.
|
127
|
-
we remind you that OpenERP tables are also named after OpenERP models but replacing the '.' by '_'.
|
130
|
+
(we remind you that OpenERP tables are also named after OpenERP models but replacing the '.' by '_'.)
|
128
131
|
|
129
132
|
Basic finders:
|
130
133
|
|
@@ -323,4 +326,4 @@ In this case [CampToCamp](http://www.camptocamp.com/) used the famous [Cucumber
|
|
323
326
|
FAQ
|
324
327
|
------------
|
325
328
|
|
326
|
-
Please read the [FAQ here](https://github.com/rvalyi/ooor/wiki/FAQ)
|
329
|
+
Please read the [FAQ here](https://github.com/rvalyi/ooor/wiki/FAQ)
|
data/bin/ooor
CHANGED
@@ -5,15 +5,7 @@ puts "*** OOOR - OpenObject on Rails! is published under the AGPL license by Akr
|
|
5
5
|
require 'irb'
|
6
6
|
require 'rubygems'
|
7
7
|
require 'ooor'
|
8
|
-
|
9
|
-
begin
|
10
|
-
#require 'bond' #auto-completion
|
11
|
-
#Bond.start
|
12
|
-
require 'irb/completion'
|
13
|
-
rescue
|
14
|
-
require 'irb/completion'
|
15
|
-
end
|
16
|
-
|
8
|
+
require 'irb/completion'
|
17
9
|
|
18
10
|
unless ARGV.empty?
|
19
11
|
username = ARGV[0].split(".")[0]
|
@@ -49,9 +41,10 @@ else
|
|
49
41
|
exit 0
|
50
42
|
end
|
51
43
|
|
52
|
-
ARGV =
|
53
|
-
ARGV
|
44
|
+
ARGV[0] = "--readline"
|
45
|
+
ARGV[1] = "--prompt"
|
46
|
+
ARGV[2] = "inf-ruby"
|
54
47
|
|
55
|
-
ooor = Ooor.new(:url => url, :database => database || 'demo', :username => username || 'admin', :password => password || 'admin')
|
48
|
+
ooor = Ooor.new(:url => url, :database => database || 'demo', :username => username || 'admin', :password => password || 'admin', :log_level => Logger::INFO)
|
56
49
|
|
57
|
-
IRB.start(__FILE__)
|
50
|
+
IRB.start(__FILE__)
|
@@ -400,9 +400,6 @@ module Ooor
|
|
400
400
|
elsif @associations.has_key?(method_name)
|
401
401
|
result = relationnal_result(method_name, *arguments)
|
402
402
|
@loaded_associations[method_name] = result and return result if result
|
403
|
-
elsif self.class.fields.has_key?(method_key) || self.class.associations_keys.index(method_name) #unloaded field/association
|
404
|
-
load(rpc_execute('read', [id], [method_key], *arguments)[0] || {})
|
405
|
-
return method_missing(method_key, *arguments)
|
406
403
|
elsif is_assign
|
407
404
|
known_associations = self.class.associations_keys + self.class.many2one_associations.collect {|k, field| self.class.const_get(field['relation']).associations_keys}.flatten
|
408
405
|
if known_associations.index(method_key)
|
@@ -412,6 +409,9 @@ module Ooor
|
|
412
409
|
end
|
413
410
|
know_fields = self.class.fields.keys + self.class.many2one_associations.collect {|k, field| self.class.const_get(field['relation']).fields.keys}.flatten
|
414
411
|
@attributes[method_key] = arguments[0] and return if know_fields.index(method_key)
|
412
|
+
elsif self.class.fields.has_key?(method_key) || self.class.associations_keys.index(method_name) #unloaded field/association
|
413
|
+
load(rpc_execute('read', [id], [method_key], *arguments)[0] || {})
|
414
|
+
return method_missing(method_key, *arguments)
|
415
415
|
elsif id #it's an action
|
416
416
|
arguments += [{}] unless arguments.last.is_a?(Hash)
|
417
417
|
rpc_execute(method_key, [id], *arguments) #we assume that's an action
|
data/lib/ooor.rb
CHANGED
@@ -52,13 +52,13 @@ module Ooor
|
|
52
52
|
def initialize(config, env=false)
|
53
53
|
@config = config.is_a?(String) ? Ooor.load_config(config, env) : config
|
54
54
|
@config.symbolize_keys!
|
55
|
-
@logger = ((defined?(Rails) && $0 != 'irb' && Rails.logger || config[:force_rails_logger]) ? Rails.logger : Logger.new($stdout))
|
56
|
-
@logger.level = config[:log_level] if config[:log_level]
|
55
|
+
@logger = ((defined?(Rails) && $0 != 'irb' && Rails.logger || @config[:force_rails_logger]) ? Rails.logger : Logger.new($stdout))
|
56
|
+
@logger.level = @config[:log_level] if @config[:log_level]
|
57
57
|
OpenObjectResource.logger = @logger
|
58
|
-
@base_url = config[:url].gsub(/\/$/,'')
|
58
|
+
@base_url = @config[:url].gsub(/\/$/,'')
|
59
59
|
@loaded_models = []
|
60
|
-
scope = Module.new and Object.const_set(config[:scope_prefix], scope) if config[:scope_prefix]
|
61
|
-
load_models() if config[:database]
|
60
|
+
scope = Module.new and Object.const_set(@config[:scope_prefix], scope) if @config[:scope_prefix]
|
61
|
+
load_models() if @config[:database]
|
62
62
|
end
|
63
63
|
|
64
64
|
def const_get(model_key)
|
@@ -101,7 +101,7 @@ module Ooor
|
|
101
101
|
klass.associations_keys = []
|
102
102
|
klass.fields = {}
|
103
103
|
klass.scope_prefix = scope_prefix
|
104
|
-
@logger.
|
104
|
+
@logger.debug "registering #{model_class_name} as an ActiveResource proxy for OpenObject #{param['model']} model"
|
105
105
|
(scope_prefix ? Object.const_get(scope_prefix) : Object).const_set(model_class_name, klass)
|
106
106
|
@loaded_models.push(klass)
|
107
107
|
klass
|
data/spec/ooor_spec.rb
CHANGED
@@ -172,6 +172,12 @@ describe Ooor do
|
|
172
172
|
end
|
173
173
|
|
174
174
|
describe "Basic creations" do
|
175
|
+
it "should be able to assign a value to an unloaded field" do
|
176
|
+
p = ProductProduct.new
|
177
|
+
p.name = "testProduct1"
|
178
|
+
p.name.should == "testProduct1"
|
179
|
+
end
|
180
|
+
|
175
181
|
it "should be able to create a product" do
|
176
182
|
p = ProductProduct.create(:name => "testProduct1", :categ_id => 1)
|
177
183
|
ProductProduct.find(p.id).categ_id.id.should == 1
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 5
|
8
|
-
-
|
9
|
-
version: 1.5.
|
8
|
+
- 3
|
9
|
+
version: 1.5.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Raphael Valyi - www.akretion.com
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-
|
17
|
+
date: 2011-07-06 00:00:00 -03:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: 2.3.5
|
33
33
|
type: :runtime
|
34
34
|
version_requirements: *id001
|
35
|
-
description: OOOR exposes business object proxies to your Ruby (Rails or not) application, that
|
35
|
+
description: OOOR exposes business object proxies to your Ruby (Rails or not) application, that maps seamlessly to your remote OpenObject/OpenERP server using webservices. It extends the standard ActiveResource API. Running on JRuby, OOOR also offers a convenient bridge between OpenERP and the Java eco-system
|
36
36
|
email: rvalyi@akretion.com
|
37
37
|
executables:
|
38
38
|
- ooor
|
@@ -90,6 +90,6 @@ rubyforge_project:
|
|
90
90
|
rubygems_version: 1.3.7
|
91
91
|
signing_key:
|
92
92
|
specification_version: 3
|
93
|
-
summary: OOOR - OpenObject On
|
93
|
+
summary: OOOR - OpenObject On Ruby
|
94
94
|
test_files: []
|
95
95
|
|