From bc67e83252d2f77bcb22592eda366baa5dee037a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 7 Jul 2010 21:27:20 +0200 Subject: [PATCH] Prefix fields with table name and quote it for issue1612 --- opportunity.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/opportunity.py b/opportunity.py index c7a5db7618..c4b64a55d6 100644 --- a/opportunity.py +++ b/opportunity.py @@ -442,20 +442,25 @@ class SaleOpportunityHistory(ModelSQL, ModelView): self._order.insert(0, ('date', 'DESC')) def _table_query_fields(self, context=None): + opportunity_obj = self.pool.get('sale.opportunity') + table = '%s__history' % opportunity_obj._table return [ - 'MIN(__id) AS id', - 'id AS opportunity', - 'MIN(COALESCE(write_date, create_date)) AS date', - 'COALESCE(write_uid, create_uid) AS user', - ] + [name for name, field in self._columns.iteritems() + 'MIN("%s".__id) AS id' % table, + '"%s".id AS opportunity' % table, + 'MIN(COALESCE("%s".write_date, "%s".create_date)) AS date' % (table, table), + 'COALESCE("%s".write_uid, "%s".create_uid) AS user' % (table, table), + ] + ['"%s"."%s"' % (table, name) for name, field in self._columns.iteritems() if name not in ('id', 'opportunity', 'date', 'user') and not hasattr(field, 'set')] def _table_query_group(self, context=None): + opportunity_obj = self.pool.get('sale.opportunity') + table = '%s__history' % opportunity_obj._table return [ - 'id', - 'COALESCE(write_uid, create_uid)', - ] + [name for name, field in self._columns.iteritems() + '"%s".id' % table, + 'COALESCE("%s".write_uid, "%s".create_uid)' % (table, table), + ] + ['"%s"."%s"' % (table, name) + for name, field in self._columns.iteritems() if name not in ('id', 'opportunity', 'date', 'user') and not hasattr(field, 'set')]