From c49d20c61a848539063e1097fc34a960ddcf354d Mon Sep 17 00:00:00 2001 From: Olivier Laurent Date: Mon, 26 Jan 2015 15:49:52 +0100 Subject: [PATCH] [FIX] base: _auto_init change column type fix When changing the type of a column (if size differs for example), 'selection' field should be considered like a 'char' field (since they are internaly the same column type) This will fix some migration issues where 'char' fields were correctly changed but not 'selection,' field. Use case: * create a 6.0 db with 'stock' module installed * 'state' field in 'stock.move' model is of type 'character varying(16)' * migrate it to 8.0 * 'state' field is still 'character varying(16)' but should normally be 'character varying' --- openerp/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openerp/models.py b/openerp/models.py index 9c3febfdaa7..e7e803f2608 100644 --- a/openerp/models.py +++ b/openerp/models.py @@ -2505,7 +2505,7 @@ class BaseModel(object): ('numeric', 'float', get_pg_type(f)[1], '::'+get_pg_type(f)[1]), ('float8', 'float', get_pg_type(f)[1], '::'+get_pg_type(f)[1]), ] - if f_pg_type == 'varchar' and f._type == 'char' and f_pg_size and (f.size is None or f_pg_size < f.size): + if f_pg_type == 'varchar' and f._type in ('char', 'selection') and f_pg_size and (f.size is None or f_pg_size < f.size): try: with cr.savepoint(): cr.execute('ALTER TABLE "%s" ALTER COLUMN "%s" TYPE %s' % (self._table, k, pg_varchar(f.size)))