ooor 1.2.4 → 1.2.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/app/models/open_object_resource.rb +18 -13
- metadata +2 -2
@@ -112,7 +112,7 @@ class OpenObjectResource < ActiveResource::Base
|
|
112
112
|
if openerp_error_hash.is_a? Hash
|
113
113
|
logger.error "*********** OpenERP Server ERROR:
|
114
114
|
#{openerp_error_hash["faultString"]}***********"
|
115
|
-
e.backtrace.each {|line| logger.error line
|
115
|
+
e.backtrace.each {|line| logger.error line unless line.index("lib/ruby")} and return nil
|
116
116
|
else
|
117
117
|
raise
|
118
118
|
end
|
@@ -186,14 +186,12 @@ class OpenObjectResource < ActiveResource::Base
|
|
186
186
|
|
187
187
|
def cast_attributes_to_ruby!
|
188
188
|
@attributes.each do |k, v|
|
189
|
-
if self.class.fields[k]
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
@attributes[k] = Date.parse(v)
|
196
|
-
end
|
189
|
+
if self.class.fields[k] && v.is_a?(String) && !v.empty?
|
190
|
+
case self.class.fields[k].ttype
|
191
|
+
when 'datetime'
|
192
|
+
@attributes[k] = Time.parse(v)
|
193
|
+
when 'date'
|
194
|
+
@attributes[k] = Date.parse(v)
|
197
195
|
end
|
198
196
|
end
|
199
197
|
end
|
@@ -233,12 +231,15 @@ class OpenObjectResource < ActiveResource::Base
|
|
233
231
|
end
|
234
232
|
|
235
233
|
@relations.each do |k, v| #see OpenERP awkward relations API
|
236
|
-
|
234
|
+
#already casted, possibly before server error!
|
235
|
+
next if (v.is_a?(Array) && v.size == 1 && v[0].is_a?(Array)) \
|
236
|
+
|| self.class.many2one_relations[k] \
|
237
|
+
|| !v.is_a?(Array)
|
237
238
|
new_rel = self.cast_relation(k, v, self.class.one2many_relations, self.class.many2many_relations)
|
238
239
|
if new_rel #matches a known o2m or m2m
|
239
240
|
@relations[k] = new_rel
|
240
241
|
else
|
241
|
-
self.class.many2one_relations.each do |k2, field| #try to cast the relation to
|
242
|
+
self.class.many2one_relations.each do |k2, field| #try to cast the relation to an inherited o2m or m2m:
|
242
243
|
linked_class = self.class.const_get(field.relation)
|
243
244
|
new_rel = self.cast_relation(k, v, linked_class.one2many_relations, linked_class.many2many_relations)
|
244
245
|
@relations[k] = new_rel and break if new_rel
|
@@ -389,8 +390,12 @@ class OpenObjectResource < ActiveResource::Base
|
|
389
390
|
self.class.reload_fields_definition() unless self.class.fields_defined
|
390
391
|
|
391
392
|
if is_assign
|
392
|
-
|
393
|
-
|
393
|
+
known_relations = self.class.relations_keys + self.class.many2one_relations.collect {|k, field| self.class.const_get(field.relation).relations_keys}.flatten
|
394
|
+
if known_relations.index(method_key)
|
395
|
+
@relations[method_key] = arguments[0]
|
396
|
+
@loaded_relations[method_key] = arguments[0]
|
397
|
+
return
|
398
|
+
end
|
394
399
|
know_fields = self.class.fields.keys + self.class.many2one_relations.collect {|k, field| self.class.const_get(field.relation).fields.keys}.flatten
|
395
400
|
@attributes[method_key] = arguments[0] and return if know_fields.index(method_key)
|
396
401
|
end
|
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.2.
|
4
|
+
version: 1.2.5
|
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: 2010-02-
|
12
|
+
date: 2010-02-05 00:00:00 -02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|