summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorAdrian Torres <adt@odoo.com>2018-07-23 07:42:57 +0200
committerGitHub <noreply@github.com>2018-07-23 07:42:57 +0200
commitcb4266787bca9722d62ee9b1b658db0d1b6d5f2a (patch)
tree2ebe51ad8d6eec70e8a96c98823f148c6e91a9a6 /addons
parente6b570c8989f211591afc5808fdb22e9f6d0d521 (diff)
[FIX] ir_model_fields: properly unlink manual fields
Before this commit: * Install module A that implements model M and field X. * Create a new custom field Y whose reference model is not M, implemented in any module other than A. * Make this field either a one2many, related or compute field depending on field X. * Uninstall module A. => The registry crashes fatally, the only way to recover from this is to log directly into the postgres database and manually eliminate the infringing ir.model.fields record. The reasons are multiple: * When creating custom fields that are relational, char fields are used to hold data like model name, field name, instead of properly storing the related field, which would let postgres handle the unlinking properly. * Despite this, the ir.model.fields method _prepare_update tries to make up for this by verifying that the ir.model.fields being unlinked during an uninstallation are not needed elsewhere and drops them, however it does so naively: It assumes that the "problematic" field will be defined within the module's scope, i.e. its model reference will be a model defined by the module being uninstalled, this isn't always the case. This is solved by getting the dependants of each field by accessing the model's field_triggers, if there are any triggers (i.e. dependants) then we add them to a `failed_dependencies` list for later processing. The same is done for field inverses (only in the case of a many2one). After finding the failed_dependencies, a check is performed to see if the unlink is being performed in the context of an uninstallation, in which case the failed dependencies will be unlinked, otherwise an error will be shown to the user. This commit is a "backport" + generalization of commit 4265026ee23ab71e8b199a9d8cbbd439409d7a03 Task-ID: 1856263
Diffstat (limited to 'addons')
0 files changed, 0 insertions, 0 deletions