[FIX] base: oversight of 547118d76f

The aforementioned commit prevented the creation of automatic xmlids for
custom fields, however this change is not exactly stable; if a database
already contains automatic xmlids for custom fields and the module to
which these xmlids belong to is upgraded, the xmlids would get deleted,
along with any records related to it because of the way that
`_update_xmlids` works.

This commit leaves existing automatic xmlids of custom fields while
preventing the creation of *new* ones.

closes odoo/odoo#34563

Signed-off-by: Christophe Simonis <chs@odoo.com>
This commit is contained in:
Adrian Torres
2019-07-04 06:47:23 +00:00
parent 67c281c6a8
commit 235a9da5db
+7 -2
View File
@@ -855,8 +855,13 @@ class IrModelFields(models.Model):
keys = [key for key in new_vals if old_vals[key] != new_vals[key]]
self.pool.post_init(record.modified, keys)
old_vals.update(new_vals)
if module and not field.manual and (module == model._original_module or module in field._modules):
to_xmlids.append(name)
if module and (module == model._original_module or module in field._modules):
# remove this and only keep the else clause if version >= saas-12.4
if field.manual:
self.pool.loaded_xmlids.add(
'%s.field_%s__%s' % (module, model._name.replace('.', '_'), name))
else:
to_xmlids.append(name)
if to_insert:
# insert missing fields