From 4dc22b73e5629a109cb6b0227806db11d3b60e79 Mon Sep 17 00:00:00 2001 From: "UCO,JVO" <> Date: Fri, 13 Nov 2009 12:56:56 +0530 Subject: [PATCH] [FIX] On Update, if only the size of column is changed,it should reflect into DB bzr revid: jvo@tinyerp.com-20091113072656-ytd8372l270lho75 --- bin/osv/orm.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/bin/osv/orm.py b/bin/osv/orm.py index c7999671b3a..16c92574936 100644 --- a/bin/osv/orm.py +++ b/bin/osv/orm.py @@ -1854,8 +1854,18 @@ class orm(orm_template): cr.commit() for c in casts: if (f_pg_type==c[0]) and (f._type==c[1]): - if f_pg_type != f_obj_type: - logger.notifyChannel('orm', netsvc.LOG_INFO, "column '%s' in table '%s' changed type to %s." % (k, self._table, c[1])) + # Adding upcoming 6 lines to check whether only the size of the fields got changed or not.E.g. :(16,3) to (16,4) + field_size_change = False + if f.digits: + field_size = (65535 * f.digits[0]) + f.digits[0] + f.digits[1] + if field_size != f_pg_size: + field_size_change = True + + if f_pg_type != f_obj_type or field_size_change: + if f_pg_type != f_obj_type: + logger.notifyChannel('orm', netsvc.LOG_INFO, "column '%s' in table '%s' changed type to %s." % (k, self._table, c[1])) + if field_size_change: + logger.notifyChannel('orm', netsvc.LOG_INFO, "column '%s' in table '%s' changed in the size." % (k, self._table)) ok = True cr.execute('ALTER TABLE "%s" RENAME COLUMN "%s" TO temp_change_size' % (self._table, k)) cr.execute('ALTER TABLE "%s" ADD COLUMN "%s" %s' % (self._table, k, c[2]))