ooor 1.0.5 → 1.0.6
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 +50 -2
- data/lib/app/models/open_object_resource.rb +2 -1
- metadata +1 -1
data/README.md
CHANGED
@@ -156,6 +156,12 @@ Request params or ActiveResource equivalence of OpenERP domain (but degraded as
|
|
156
156
|
$ Partners.find(:all, :params => {:supplier => true})
|
157
157
|
|
158
158
|
|
159
|
+
OpenERP search method:
|
160
|
+
|
161
|
+
$ ResPartner.search([['name', 'ilike', 'a']], 0, 2)
|
162
|
+
Arguments are: domain, offset=0, limit=false, order=false, context={}, count=false
|
163
|
+
|
164
|
+
|
159
165
|
Relations (many2one, one2many, many2many) support:
|
160
166
|
|
161
167
|
$ SaleOrder.find(1).order_line
|
@@ -170,6 +176,12 @@ Inherited relations support:
|
|
170
176
|
|
171
177
|
$ ProductProduct.find(1).categ_id #where categ_id is inherited from the ProductTemplate
|
172
178
|
|
179
|
+
Please notice that loaded relations are cached (to avoid hitting OpenERP over and over)
|
180
|
+
until the root object is reloaded (after save/update for instance)
|
181
|
+
Currently, save/update doesn't save the whole object graph but only the current object.
|
182
|
+
We might change this in the future to match the way OpenERP clients are working which
|
183
|
+
is supported by the OpenERP ORM, see issue: http://github.com/rvalyi/ooor/issues/#issue/3
|
184
|
+
|
173
185
|
|
174
186
|
Load only specific fields support (faster than loading all fields):
|
175
187
|
|
@@ -205,10 +217,46 @@ Delete:
|
|
205
217
|
$ pc.destroy
|
206
218
|
|
207
219
|
|
208
|
-
Call workflow:
|
220
|
+
Call workflow:
|
221
|
+
|
222
|
+
$ s = SaleOrder.find(2)
|
223
|
+
$ s.wkf_action('cancel')
|
224
|
+
$ s.state
|
225
|
+
$ => 'cancel'
|
226
|
+
|
227
|
+
|
228
|
+
On Change methods:
|
229
|
+
|
230
|
+
$ l=SaleOrderLine.new
|
231
|
+
$ l.on_change('product_id_change', 1, 1, false, false, false, false, false, false, 1)
|
232
|
+
$ => #<Ooor::SaleOrderLine:0x10c2cfe1 @prefix_options={}, @attributes={"product_packaging"=>false, "product_uos_qty"=>false, "th_weight"=>0}>
|
233
|
+
Notice that it reloads the Objects attrs and print warning message accordingly
|
234
|
+
|
235
|
+
|
236
|
+
Call aribtrary method:
|
237
|
+
|
238
|
+
$ use static ObjectClass.rpc_execute_with_all method
|
239
|
+
$ or object.call(method_name, args*) #were args is an aribtrary list of arguments
|
240
|
+
|
241
|
+
|
242
|
+
Change logged user:
|
243
|
+
|
244
|
+
$ Ooor.global_login('demo', 'demo')
|
245
|
+
$ s = SaleOrder.find(2)
|
246
|
+
$ => 'Access denied error'
|
247
|
+
Notice that this changes the globally logged user and doesn't address the issue of
|
248
|
+
different users using Ooor concurrently with different credentials as you might want
|
249
|
+
for instance in a Rails web application. That second issue will be addressed at
|
250
|
+
the API level but it's not easy as ActiveResource has not been designed for it.
|
251
|
+
|
252
|
+
|
253
|
+
Change log level:
|
209
254
|
|
255
|
+
By default the log level is very verbose (debug level) to help newcomers to jumpstart
|
256
|
+
However you might want to change that. 2 solutions:
|
257
|
+
$ Ooor.logger.level = 1 #available levels are those of the standard Ruby Logger class: 0 debug, 1 info, 2 error
|
258
|
+
$ In the config yaml file or hash, set the :log_level parameter
|
210
259
|
|
211
|
-
Call aribtrary method: see code; TODO document
|
212
260
|
|
213
261
|
|
214
262
|
REST HTTP API:
|
@@ -94,6 +94,7 @@ class OpenObjectResource < ActiveResource::Base
|
|
94
94
|
|
95
95
|
#corresponding method for OpenERP osv.execute(self, db, uid, obj, method, *args, **kw) method
|
96
96
|
def rpc_execute_with_all(db, uid, pass, obj, method, *args)
|
97
|
+
logger.debug "rpc_execute_with_all: rpc_methods: 'execute', db: #{db.inspect}, uid: #{uid.inspect}, pass: #{pass.inspect}, obj: #{obj.inspect}, method: #{method}, *args: #{args.inspect}"
|
97
98
|
try_with_pretty_error_log { client(@database && @site || Ooor.object_url).call("execute", db, uid, pass, obj, method, *args) }
|
98
99
|
end
|
99
100
|
|
@@ -107,6 +108,7 @@ class OpenObjectResource < ActiveResource::Base
|
|
107
108
|
end
|
108
109
|
|
109
110
|
def rpc_exec_workflow_with_all(db, uid, pass, obj, action, *args)
|
111
|
+
logger.debug "rpc_execute_with_all: rpc_methods: 'exec_workflow', db: #{db.inspect}, uid: #{uid.inspect}, pass: #{pass.inspect}, obj: #{obj.inspect}, action #{action}, *args: #{args.inspect}"
|
110
112
|
try_with_pretty_error_log { client(@database && @site || Ooor.object_url).call("exec_workflow", db, uid, pass, obj, action, *args) }
|
111
113
|
end
|
112
114
|
|
@@ -248,7 +250,6 @@ class OpenObjectResource < ActiveResource::Base
|
|
248
250
|
#Generic OpenERP on_change method
|
249
251
|
def on_change(on_change_method, *args)
|
250
252
|
result = self.class.rpc_execute(on_change_method, *args)
|
251
|
-
session
|
252
253
|
self.classlogger.info result["warning"]["title"] if result["warning"]
|
253
254
|
self.class.logger.info result["warning"]["message"] if result["warning"]
|
254
255
|
load(result["value"])
|