Bugfix ORM _inherits

bzr revid: fp@tinyerp.com-20080819214253-nd4e5ym37lhyv2jj
This commit is contained in:
Fabien Pinckaers 2008-08-19 23:42:53 +02:00
parent 661982c072
commit 62ae90231b
2 changed files with 8 additions and 4 deletions

View File

@ -84,7 +84,8 @@ class expression(object):
if left in table._inherit_fields:
working_table = table.pool.get(table._inherit_fields[left][0])
if working_table not in self.__tables.values():
self.__joins.append('%s.%s' % (table._table, table._inherits[working_table._name]))
self.__joins.append(('%s.%s=%s.%s' % (working_table._table, 'id', table._table, table._inherits[working_table._name]), working_table._table))
print 'JOINS', self.__joins
self.__tables[i] = working_table
@ -286,13 +287,13 @@ class expression(object):
stack.append('(%s %s %s)' % (q1, ops[e], q2,))
query = ' AND '.join(reversed(stack))
joins = ' AND '.join(map(lambda j: '%s.id = %s' % (self.__main_table._table, j), self.__joins))
joins = ' AND '.join(map(lambda j: j[0], self.__joins))
if joins:
query = '(%s AND (%s))' % (joins, query)
query = '(%s) AND (%s)' % (joins, query)
return (query, flatten(params))
def get_tables(self):
return ['"%s"' % t._table for t in set(self.__tables.values())]
return ['"%s"' % t._table for t in set(self.__tables.values()+[self.__main_table])]
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -2336,6 +2336,7 @@ class orm(orm_template):
else:
qu1, qu2, tables = [], [], ['"%s"' % self._table]
print 'WC RES', qu1, qu2, tables
return (qu1, qu2, tables)
def _check_qorder(self, word):
@ -2345,10 +2346,12 @@ class orm(orm_template):
def search(self, cr, user, args, offset=0, limit=None, order=None,
context=None, count=False):
print 'SEARCH', self._name, args
if not context:
context = {}
# compute the where, order by, limit and offset clauses
(qu1, qu2, tables) = self._where_calc(cr, user, args, context=context)
print qu1, qu2, tables
if len(qu1):
qu1 = ' where '+string.join(qu1, ' and ')