Rifakat (OpenERP) has proposed merging
lp:~openerp-dev/openobject-server/6.0-opw-578249-rha into
lp:openobject-server/6.0.
Requested reviews:
Naresh(OpenERP) (nch-openerp)
Olivier Dony (OpenERP) (odo-openerp)
Related bugs:
Bug #1018908 in OpenERP Server: "fields.function stored with multi argument
and mixed integer/manyone types"
https://bugs.launchpad.net/openobject-server/+bug/1018908
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-server/6.0-opw-578249-rha/+merge/121826
Hello,
Fixed issue for fields.function with multi argument, it is mixing up the type
when
we use multi argument for different type int & m2o.
When int field comes in higher execution order in list of fields in that case
it gets
its value based on int type and convert the value into string which may cause
problem.
This fix converted int value to float instead of string while value is greater
than xmlrpc limit.
This is a partial backport from stable 6.1
Thanks for your review.
Sincerely,
Rifakat Haradwala
--
https://code.launchpad.net/~openerp-dev/openobject-server/6.0-opw-578249-rha/+merge/121826
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-server/6.0-opw-578249-rha.
=== modified file 'bin/osv/fields.py'
--- bin/osv/fields.py 2012-03-14 12:49:12 +0000
+++ bin/osv/fields.py 2012-08-29 10:53:52 +0000
@@ -803,6 +803,34 @@
return []
return self._fnct_search(obj, cr, uid, obj, name, args, context=context)
+ def postprocess(self, cr, uid, obj, field, value=None, context=None):
+ if context is None:
+ context = {}
+ result = value
+ field_type = obj._columns[field]._type
+ if field_type == "many2one":
+ # make the result a tuple if it is not already one
+ if isinstance(value, (int,long)) and hasattr(obj._columns[field], 'relation'):
+ obj_model = obj.pool.get(obj._columns[field].relation)
+ dict_names = dict(obj_model.name_get(cr, uid, [value], context))
+ result = (value, dict_names[value])
+
+ if field_type == 'binary':
+ if context.get('bin_size'):
+ # client requests only the size of binary fields
+ result = get_nice_size((None,value))[1]
+ else:
+ result = sanitize_binary_value((None,value))[1]
+
+ if field_type == "integer" and value > xmlrpclib.MAXINT:
+ # integer/long values greater than 2^31-1 are not supported
+ # in pure XMLRPC, so we have to pass them as floats :-(
+ # This is not needed for stored fields and non-functional integer
+ # fields, as their values are constrained by the database backend
+ # to the same 32bits signed int limit.
+ result = __builtin__.float(value)
+ return result
+
def get(self, cr, obj, ids, name, user=None, context=None, values=None):
if context is None:
context = {}
@@ -813,33 +841,13 @@
res = self._fnct(obj, cr, user, ids, name, self._arg, context)
else:
res = self._fnct(cr, obj._table, ids, name, self._arg, context)
-
- if self._type == "many2one" :
- # Filtering only integer/long values if passed
- res_ids = [x for x in res.values() if x and isinstance(x, (int,long))]
-
- if res_ids:
- obj_model = obj.pool.get(self._obj)
- dict_names = dict(obj_model.name_get(cr, user, res_ids, context))
- for r in res.keys():
- if res[r] and res[r] in dict_names:
- res[r] = (res[r], dict_names[res[r]])
-
- if self._type == 'binary':
- if context.get('bin_size', False):
- # client requests only the size of binary fields
- res = dict(map(get_nice_size, res.items()))
- else:
- res = dict(map(sanitize_binary_value, res.items()))
-
- if self._type == "integer":
- for r in res.keys():
- # Converting value into string so that it does not affect XML-RPC Limits
- if isinstance(res[r],dict): # To treat integer values with _multi attribute
- for record in res[r].keys():
- res[r][record] = str(res[r][record])
- else:
- res[r] = str(res[r])
+ for id in ids:
+ if self._multi and id in res:
+ for field, value in res[id].iteritems():
+ if value:
+ res[id][field] = self.postprocess(cr, user, obj, field, value, context)
+ elif res.get(id):
+ res[id] = self.postprocess(cr, user, obj, name, res[id], context)
return res
get_memory = get
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp