[IMP] core: remove support of oldname attribute
This attribute is misleading as it is insufficient to correctly upgrade the database. It only renames the column in the database, but other operations are needed, like updating the corresponding `ir.model.fields` record (and its xmlid). The default values and the translations are also lost during the upgrade. Moreover, this feature was misused. It was: - left on fields during multiple versions. - used on reports (SQL views). This would be ok if the feature was complete, but, as is, it was useless. - kept unchanged after a second renaming of the field (which can happen versions later the first rename). - used, even when the meaning of the field changed. i.e. the field `archived` has been renamed to the classic `active`, but the value in the database should be switched. closes odoo/odoo#35439 Signed-off-by: Christophe Simonis <chs@odoo.com>
This commit is contained in:
+5
-8
@@ -34,6 +34,7 @@ DATETIME_LENGTH = len(datetime.now().strftime(DATETIME_FORMAT))
|
||||
EMPTY_DICT = frozendict()
|
||||
|
||||
RENAMED_ATTRS = [('select', 'index'), ('digits_compute', 'digits')]
|
||||
DEPRECATED_ATTRS = [("oldname", "use an upgrade script instead.")]
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
_schema = logging.getLogger(__name__[:-7] + '.schema')
|
||||
@@ -137,9 +138,6 @@ class Field(MetaField('DummyField', (object,), {})):
|
||||
``one2many`` and computed fields, including property fields and
|
||||
related fields)
|
||||
|
||||
:param string oldname: the previous name of this field, so that ORM can rename
|
||||
it automatically at migration
|
||||
|
||||
.. _field-computed:
|
||||
|
||||
.. rubric:: Computed fields
|
||||
@@ -452,6 +450,10 @@ class Field(MetaField('DummyField', (object,), {})):
|
||||
if key1 in attrs:
|
||||
_logger.warning("Field %s: parameter %r is no longer supported; use %r instead.",
|
||||
self, key1, key2)
|
||||
for key, msg in DEPRECATED_ATTRS:
|
||||
if key in attrs:
|
||||
_logger.warning("Field %s: parameter %r is not longer supported; %s",
|
||||
self, key, msg)
|
||||
|
||||
# prefetch only stored, column, non-manual and non-deprecated fields
|
||||
if not (self.store and self.column_type) or self.manual or self.deprecated:
|
||||
@@ -882,11 +884,6 @@ class Field(MetaField('DummyField', (object,), {})):
|
||||
return
|
||||
|
||||
column = columns.get(self.name)
|
||||
if not column and hasattr(self, 'oldname'):
|
||||
# column not found; check whether it exists under its old name
|
||||
column = columns.get(self.oldname)
|
||||
if column:
|
||||
sql.rename_column(model._cr, model._table, self.oldname, self.name)
|
||||
|
||||
# create/update the column, not null constraint, indexes
|
||||
self.update_db_column(model, column)
|
||||
|
||||
Reference in New Issue
Block a user