summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Torres <adt@odoo.com>2018-06-04 11:30:49 +0200
committerGitHub <noreply@github.com>2018-06-04 11:30:49 +0200
commit661542a4a7b64d3e8d0de6331fdd94765c855faa (patch)
tree1d74a099b582379e8078029573ea8c6b2c1ec05c
parent75c44c47787a2e6c6107fdebd7f39c409b1ddf9a (diff)
[FIX] account, l10n_generic_coa: remove unused master data
When installing the `account` module, some of its master data is installed as `l10n_generic_coa` data. During the uninstallation of `account`, `l10n_generic_coa` is uninstalled first since its a dependency of `account`, but some of its master data cannot be uninstalled yet as its still being referenced in some `account` et al tables. When `account` is being reinstalled, the datas will be updated instead of created since they were left intact in the database, this proves troublesome as the code YAML interpreter adds some context variables when creating records but not when updating records, these context variables are necessary in order to trigger some onchanges and defaults for fields that are required, since this does not happen we get a `NOT NULL CONSTRAINT` error when re-installing the `account` module. This patch solves this issue by adding an uninstall_hook that will delete all ir_model_data that belongs to the module `l10n_generic_coa` upon its uninstallation. Fixes #25005
-rw-r--r--addons/l10n_generic_coa/__init__.py6
-rw-r--r--addons/l10n_generic_coa/__manifest__.py1
2 files changed, 7 insertions, 0 deletions
diff --git a/addons/l10n_generic_coa/__init__.py b/addons/l10n_generic_coa/__init__.py
index 67dee8c60db..d417dc6807c 100644
--- a/addons/l10n_generic_coa/__init__.py
+++ b/addons/l10n_generic_coa/__init__.py
@@ -1,2 +1,8 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+
+def uninstall_hook(cr, registry):
+ cr.execute(
+ "DELETE FROM ir_model_data WHERE module = 'l10n_generic_coa'"
+ )
diff --git a/addons/l10n_generic_coa/__manifest__.py b/addons/l10n_generic_coa/__manifest__.py
index 9d5287e6250..a3ceb0f8273 100644
--- a/addons/l10n_generic_coa/__manifest__.py
+++ b/addons/l10n_generic_coa/__manifest__.py
@@ -28,4 +28,5 @@ Install some generic chart of accounts.
'../account/demo/account_invoice_demo.yml',
],
'website': 'https://www.odoo.com/page/accounting',
+ 'uninstall_hook': 'uninstall_hook',
}