ooor 1.0.2 → 1.0.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 CHANGED
@@ -141,6 +141,9 @@ Basic finders:
141
141
  OpenERP domain support:
142
142
 
143
143
  $ ResPartner.find(:all, :domain=>[['supplier', '=', 1],['active','=',1]])
144
+ More subbtle now, remember OpenERP use a kind of inverse polish notation for complex domains,
145
+ here we look for a product in category 1 AND which name is either 'PC1' OR 'PC2':
146
+ $ ProductProduct.find(:all, :domain=>[['categ_id','=',1],'|',['name', '=', 'PC1'],['name','=','PC2']])
144
147
 
145
148
 
146
149
  OpenERP context support:
@@ -192,6 +195,11 @@ Update:
192
195
  $ pc.save
193
196
 
194
197
 
198
+ Copy:
199
+
200
+ $ copied_object = pc.copy({:categ_id => 2}) #first optionnal arg is new default values, second is context
201
+
202
+
195
203
  Delete:
196
204
 
197
205
  $ pc.destroy
@@ -44,7 +44,7 @@ class OpenObjectResource < ActiveResource::Base
44
44
  @fields[field.attributes['name']] = field
45
45
  end
46
46
  end
47
- logger.info "#{fields.size} fields"
47
+ logger.info "#{fields.size} fields loaded"
48
48
  end
49
49
  @field_defined = true
50
50
  end
@@ -209,12 +209,14 @@ class OpenObjectResource < ActiveResource::Base
209
209
  def create(context={})
210
210
  self.pre_cast_attributes
211
211
  self.id = self.class.rpc_execute('create', @attributes, context)
212
+ load(self.class.find(self.id, :context => context).attributes)
212
213
  end
213
214
 
214
215
  #compatible with the Rails way but also supports OpenERP context
215
216
  def update(context={})
216
217
  self.pre_cast_attributes
217
218
  self.class.rpc_execute('write', self.id, @attributes.reject{|k, v| k == 'id'}, context)
219
+ load(self.class.find(self.id, :context => context).attributes)
218
220
  end
219
221
 
220
222
  #compatible with the Rails way but also supports OpenERP context
@@ -222,11 +224,16 @@ class OpenObjectResource < ActiveResource::Base
222
224
  self.class.rpc_execute('unlink', self.id, context)
223
225
  end
224
226
 
227
+ #OpenERP copy method, load persisted copied Object
228
+ def copy(defaults=[], context={})
229
+ self.class.find(self.class.rpc_execute('copy', self.id, defaults, context), :context => context)
230
+ end
231
+
225
232
 
226
233
  # ******************** fake associations like much like ActiveRecord according to the cached OpenERP data model ********************
227
234
 
228
235
  def relations
229
- @relations ||= {} and @relations
236
+ @relations ||= {} and @relations
230
237
  end
231
238
 
232
239
  def relationnal_result(method_id, *arguments)
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.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Raphael Valyi - www.akretion.com