From 3d3534ca39b05c847965daf60597f29e20a82752 Mon Sep 17 00:00:00 2001 From: Christophe CHAUVET Date: Thu, 6 Dec 2012 17:37:11 +0100 Subject: [PATCH 1/2] [IMP] Don't use WITH OIDS when create a table lp bug: https://launchpad.net/bugs/1087332 fixed bzr revid: christophe.chauvet@syleam.fr-20121206163711-5jvrhrg8w5le4zay --- openerp/osv/orm.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/openerp/osv/orm.py b/openerp/osv/orm.py index ef13253864b..40c15a217c7 100644 --- a/openerp/osv/orm.py +++ b/openerp/osv/orm.py @@ -2287,7 +2287,7 @@ class BaseModel(object): if view_type == 'tree' or not action[2].get('multi')] resprint = [clean(print_) for print_ in resprint if view_type == 'tree' or not print_[2].get('multi')] - #When multi="True" set it will display only in More of the list view + #When multi="True" set it will display only in More of the list view resrelate = [clean(action) for action in resrelate if (action[2].get('multi') and view_type == 'tree') or (not action[2].get('multi') and view_type == 'form')] @@ -2681,17 +2681,17 @@ class BaseModel(object): order = orderby or groupby data_ids = self.search(cr, uid, [('id', 'in', alldata.keys())], order=order, context=context) - + # the IDs of records that have groupby field value = False or '' should be included too data_ids += set(alldata.keys()).difference(data_ids) - - if groupby: + + if groupby: data = self.read(cr, uid, data_ids, [groupby], context=context) # restore order of the search as read() uses the default _order (this is only for groups, so the footprint of data should be small): data_dict = dict((d['id'], d[groupby] ) for d in data) result = [{'id': i, groupby: data_dict[i]} for i in data_ids] else: - result = [{'id': i} for i in data_ids] + result = [{'id': i} for i in data_ids] for d in result: if groupby: @@ -3318,7 +3318,7 @@ class BaseModel(object): raise except_orm('Programming Error', ('Many2Many destination model does not exist: `%s`') % (f._obj,)) dest_model = self.pool.get(f._obj) ref = dest_model._table - cr.execute('CREATE TABLE "%s" ("%s" INTEGER NOT NULL, "%s" INTEGER NOT NULL, UNIQUE("%s","%s")) WITH OIDS' % (m2m_tbl, col1, col2, col1, col2)) + cr.execute('CREATE TABLE "%s" ("%s" INTEGER NOT NULL, "%s" INTEGER NOT NULL, UNIQUE("%s","%s")) WITHOUT OIDS' % (m2m_tbl, col1, col2, col1, col2)) # create foreign key references with ondelete=cascade, unless the targets are SQL views cr.execute("SELECT relkind FROM pg_class WHERE relkind IN ('v') AND relname=%s", (ref,)) if not cr.fetchall(): @@ -3835,7 +3835,7 @@ class BaseModel(object): if operation in ('read','unlink'): # No need to warn about deleting an already deleted record. # And no error when reading a record that was deleted, to prevent spurious - # errors for non-transactional search/read sequences coming from clients + # errors for non-transactional search/read sequences coming from clients return _logger.warning('Failed operation on deleted record(s): %s, uid: %s, model: %s', operation, uid, self._name) raise except_orm(_('Missing document(s)'), @@ -4322,12 +4322,12 @@ class BaseModel(object): del vals[self._inherits[table]] record_id = tocreate[table].pop('id', None) - + # When linking/creating parent records, force context without 'no_store_function' key that - # defers stored functions computing, as these won't be computed in batch at the end of create(). + # defers stored functions computing, as these won't be computed in batch at the end of create(). parent_context = dict(context) parent_context.pop('no_store_function', None) - + if record_id is None or not record_id: record_id = self.pool.get(table).create(cr, user, tocreate[table], context=parent_context) else: @@ -4376,7 +4376,7 @@ class BaseModel(object): upd0 = upd0 + ',"' + field + '"' upd1 = upd1 + ',' + self._columns[field]._symbol_set[0] upd2.append(self._columns[field]._symbol_set[1](vals[field])) - #for the function fields that receive a value, we set them directly in the database + #for the function fields that receive a value, we set them directly in the database #(they may be required), but we also need to trigger the _fct_inv() if (hasattr(self._columns[field], '_fnct_inv')) and not isinstance(self._columns[field], fields.related): #TODO: this way to special case the related fields is really creepy but it shouldn't be changed at From 82b17c82a45b1d39d98b85d2c1331834a64cba95 Mon Sep 17 00:00:00 2001 From: Christophe CHAUVET Date: Fri, 7 Dec 2012 17:21:10 +0100 Subject: [PATCH 2/2] [IMP] Remove completly the OIDS, cause WITHOUT OIDS is activate by default bzr revid: christophe.chauvet@syleam.fr-20121207162110-75hbq71zc6ufeby9 --- openerp/osv/orm.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/openerp/osv/orm.py b/openerp/osv/orm.py index 40c15a217c7..1dd3552fc95 100644 --- a/openerp/osv/orm.py +++ b/openerp/osv/orm.py @@ -2287,7 +2287,7 @@ class BaseModel(object): if view_type == 'tree' or not action[2].get('multi')] resprint = [clean(print_) for print_ in resprint if view_type == 'tree' or not print_[2].get('multi')] - #When multi="True" set it will display only in More of the list view + #When multi="True" set it will display only in More of the list view resrelate = [clean(action) for action in resrelate if (action[2].get('multi') and view_type == 'tree') or (not action[2].get('multi') and view_type == 'form')] @@ -2681,17 +2681,17 @@ class BaseModel(object): order = orderby or groupby data_ids = self.search(cr, uid, [('id', 'in', alldata.keys())], order=order, context=context) - + # the IDs of records that have groupby field value = False or '' should be included too data_ids += set(alldata.keys()).difference(data_ids) - - if groupby: + + if groupby: data = self.read(cr, uid, data_ids, [groupby], context=context) # restore order of the search as read() uses the default _order (this is only for groups, so the footprint of data should be small): data_dict = dict((d['id'], d[groupby] ) for d in data) result = [{'id': i, groupby: data_dict[i]} for i in data_ids] else: - result = [{'id': i} for i in data_ids] + result = [{'id': i} for i in data_ids] for d in result: if groupby: @@ -3234,7 +3234,7 @@ class BaseModel(object): def _create_table(self, cr): - cr.execute('CREATE TABLE "%s" (id SERIAL NOT NULL, PRIMARY KEY(id)) WITHOUT OIDS' % (self._table,)) + cr.execute('CREATE TABLE "%s" (id SERIAL NOT NULL, PRIMARY KEY(id))' % (self._table,)) cr.execute(("COMMENT ON TABLE \"%s\" IS %%s" % self._table), (self._description,)) _schema.debug("Table '%s': created", self._table) @@ -3318,7 +3318,7 @@ class BaseModel(object): raise except_orm('Programming Error', ('Many2Many destination model does not exist: `%s`') % (f._obj,)) dest_model = self.pool.get(f._obj) ref = dest_model._table - cr.execute('CREATE TABLE "%s" ("%s" INTEGER NOT NULL, "%s" INTEGER NOT NULL, UNIQUE("%s","%s")) WITHOUT OIDS' % (m2m_tbl, col1, col2, col1, col2)) + cr.execute('CREATE TABLE "%s" ("%s" INTEGER NOT NULL, "%s" INTEGER NOT NULL, UNIQUE("%s","%s"))' % (m2m_tbl, col1, col2, col1, col2)) # create foreign key references with ondelete=cascade, unless the targets are SQL views cr.execute("SELECT relkind FROM pg_class WHERE relkind IN ('v') AND relname=%s", (ref,)) if not cr.fetchall(): @@ -3835,7 +3835,7 @@ class BaseModel(object): if operation in ('read','unlink'): # No need to warn about deleting an already deleted record. # And no error when reading a record that was deleted, to prevent spurious - # errors for non-transactional search/read sequences coming from clients + # errors for non-transactional search/read sequences coming from clients return _logger.warning('Failed operation on deleted record(s): %s, uid: %s, model: %s', operation, uid, self._name) raise except_orm(_('Missing document(s)'), @@ -4322,12 +4322,12 @@ class BaseModel(object): del vals[self._inherits[table]] record_id = tocreate[table].pop('id', None) - + # When linking/creating parent records, force context without 'no_store_function' key that - # defers stored functions computing, as these won't be computed in batch at the end of create(). + # defers stored functions computing, as these won't be computed in batch at the end of create(). parent_context = dict(context) parent_context.pop('no_store_function', None) - + if record_id is None or not record_id: record_id = self.pool.get(table).create(cr, user, tocreate[table], context=parent_context) else: @@ -4376,7 +4376,7 @@ class BaseModel(object): upd0 = upd0 + ',"' + field + '"' upd1 = upd1 + ',' + self._columns[field]._symbol_set[0] upd2.append(self._columns[field]._symbol_set[1](vals[field])) - #for the function fields that receive a value, we set them directly in the database + #for the function fields that receive a value, we set them directly in the database #(they may be required), but we also need to trigger the _fct_inv() if (hasattr(self._columns[field], '_fnct_inv')) and not isinstance(self._columns[field], fields.related): #TODO: this way to special case the related fields is really creepy but it shouldn't be changed at