[FIX]: fix the problem for related fields, related fields act as a many2one fields
authorMantavya Gajjar <mga@tinyerp.com>
Mon, 14 Sep 2009 10:46:58 +0000 (16:16 +0530)
committerMantavya Gajjar <mga@tinyerp.com>
Mon, 14 Sep 2009 10:46:58 +0000 (16:16 +0530)
which is not exist in the db , so direct ql query will not work for them, direct sql will work only
for many2one fields only to make relation with 2 tables

lp bug: https://launchpad.net/bugs/379191 fixed

bzr revid: mga@tinyerp.com-20090914104658-8submdrc2pjwflhy

addons/base_report_creator/base_report_creator.py

index afe1ba3..0f3c118 100644 (file)
@@ -214,13 +214,16 @@ class report_creator(osv.osv):
                     reference_model_dict[v.get('relation')] = relation_count+1
                 else:
                     reference_model_dict[v.get('relation')]=1
-                str_where = model_dict.get(model)+"."+ k + "=" + model_dict.get(v.get('relation'))+'.id' 
-                where_list.append(str_where)
+                   
+                if isinstance(self.pool.get(model)._columns.get(k), fields.many2one):
+                    str_where = model_dict.get(model)+"."+ k + "=" + model_dict.get(v.get('relation'))+'.id'
+                    where_list.append(str_where)
         if reference_model_dict:
             self.model_set_id = model_dict.get(reference_model_dict.keys()[reference_model_dict.values().index(min(reference_model_dict.values()))])
         if model_list and not len(model_dict.keys()) == 1:
             raise osv.except_osv(_('No Related Models!!'),_('These is/are model(s) (%s) in selection which is/are not related to any other model') % ','.join(model_list))
         
+        print 'where_list : ', where_list
         if filter_ids and where_list<>[]:
             filter_list.append(' and ')
             filter_list.append(' ')