ooor 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +3 -3
- data/lib/app/models/open_object_resource.rb +27 -4
- data/lib/ooor.rb +1 -0
- metadata +2 -2
data/README.md
CHANGED
@@ -59,12 +59,12 @@ OpenERP is a Python based open source ERP. Every action in OpenERP is actually i
|
|
59
59
|
OOOR just takes advantage of brings this power your favorite web development tool - Rails - with OpenERP domain objects and business methods.
|
60
60
|
|
61
61
|
OOOR aims at being a very simple piece of code (< 500 lines of code; e.g no bug, easy to evolve) adhering to Rails standards.
|
62
|
-
So instead of re-inventing the wheel, OOOR basically just sits on the top of Rails ActiveResource::Base, the standard way of remoting you ActiveRecord Rails models with REST.
|
62
|
+
So instead of re-inventing the wheel, OOOR basically just sits on the top of Rails [ActiveResource::Base](http://api.rubyonrails.org/classes/ActiveResource/Base.html), the standard way of remoting you ActiveRecord Rails models with REST.
|
63
63
|
|
64
|
-
Remember, ActiveResource is actually simpler than ActiveRecord. It's aimed at remoting ANY object model, not necessarily ActiveRecord models.
|
64
|
+
Remember, ActiveResource is actually simpler than [ActiveRecord](http://api.rubyonrails.org/classes/ActiveRecord/Base.html). It's aimed at remoting ANY object model, not necessarily ActiveRecord models.
|
65
65
|
So ActiveResource is only a subset of ActiveRecord, sharing the common denominator API (integration is expected to become even more powerful in Rails 3).
|
66
66
|
|
67
|
-
OOOR implements ActiveResource public API almost fully. It means that you can remotely work on any OpenERP model using the standard ActiveResource API.
|
67
|
+
OOOR implements ActiveResource public API almost fully. It means that you can remotely work on any OpenERP model using [the standard ActiveResource API](http://api.rubyonrails.org/classes/ActiveResource/Base.html).
|
68
68
|
|
69
69
|
But, OOOR goes actually a bit further: it does implements model associations (one2many, many2many, many2one, single table inheritance).
|
70
70
|
Indeed, when loading the OpenERP models, we load the relational meta-model using OpenERP standard datamodel introspection services.
|
@@ -79,6 +79,11 @@ class OpenObjectResource < ActiveResource::Base
|
|
79
79
|
|
80
80
|
# ******************** remote communication ********************
|
81
81
|
|
82
|
+
#OpenERP search method
|
83
|
+
def search(domain, offset=0, limit=false, order=false, context={}, count=false)
|
84
|
+
rpc_execute('search', domain, offset, limit, order, context, count)
|
85
|
+
end
|
86
|
+
|
82
87
|
def client
|
83
88
|
@client ||= XMLRPC::Client.new2(@site.to_s.gsub(/\/$/,'')) #always remove trailing / to make OpenERP happy
|
84
89
|
end
|
@@ -115,10 +120,15 @@ class OpenObjectResource < ActiveResource::Base
|
|
115
120
|
def try_with_pretty_error_log
|
116
121
|
yield
|
117
122
|
rescue RuntimeError => e
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
123
|
+
begin
|
124
|
+
openerp_error_hash = eval("#{ e }".gsub("wrong fault-structure: ", ""))
|
125
|
+
if openerp_error_hash.is_a? Hash
|
126
|
+
logger.error "*********** OpenERP Server ERROR:
|
127
|
+
#{openerp_error_hash["faultString"]}
|
128
|
+
***********"
|
129
|
+
end
|
130
|
+
rescue
|
131
|
+
end
|
122
132
|
raise
|
123
133
|
end
|
124
134
|
|
@@ -229,6 +239,19 @@ class OpenObjectResource < ActiveResource::Base
|
|
229
239
|
self.class.find(self.class.rpc_execute('copy', self.id, defaults, context), :context => context)
|
230
240
|
end
|
231
241
|
|
242
|
+
#Generic OpenERP rpc method call
|
243
|
+
def call(method, *args)
|
244
|
+
self.class.rpc_execute(method, *args)
|
245
|
+
end
|
246
|
+
|
247
|
+
#Generic OpenERP on_change method
|
248
|
+
def on_change(on_change_method, *args)
|
249
|
+
result = self.class.rpc_execute(on_change_method, *args)
|
250
|
+
self.classlogger.info result["warning"]["title"] if result["warning"]
|
251
|
+
self.class.logger.info result["warning"]["message"] if result["warning"]
|
252
|
+
load(result["value"])
|
253
|
+
end
|
254
|
+
|
232
255
|
|
233
256
|
# ******************** fake associations like much like ActiveRecord according to the cached OpenERP data model ********************
|
234
257
|
|
data/lib/ooor.rb
CHANGED
@@ -30,6 +30,7 @@ module Ooor
|
|
30
30
|
database = @ooor_config[:database]
|
31
31
|
user = @ooor_config[:username]
|
32
32
|
pass = @ooor_config[:password]
|
33
|
+
@ooor_logger.level = @ooor_config[:log_level] if @ooor_config[:log_level]
|
33
34
|
rescue Exception => error
|
34
35
|
@ooor_logger.error """ooor.yml failed: #{error.inspect}
|
35
36
|
#{error.backtrace}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ooor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Raphael Valyi - www.akretion.com
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-11-04 00:00:00 -02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|