[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'
This commit is contained in:
parent
801a8b8fa9
commit
c49d20c61a
|
@ -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)))
|
||||
|
|
Loading…
Reference in New Issue