From ce0c60e15212e595354e35cb0b1ae9ce652b46db Mon Sep 17 00:00:00 2001 From: "Jay (Open ERP)" Date: Thu, 27 Aug 2009 19:49:22 +0530 Subject: [PATCH] [FIX] Functional fields with M2O relation can be printed on print screen now lp bug: https://launchpad.net/bugs/415391 fixed bzr revid: jvo@tinyerp.com-20090827141922-aapmtmc50y168jun --- bin/osv/fields.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/bin/osv/fields.py b/bin/osv/fields.py index ee235e95eca..dbd37ec8a76 100644 --- a/bin/osv/fields.py +++ b/bin/osv/fields.py @@ -641,6 +641,17 @@ class function(_column): 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' and context.get('bin_size', False): # convert the data returned by the function with the size of that data... res = dict(map(lambda (x, y): (x, tools.human_size(len(y or ''))), res.items()))