summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorAdrian Torres <adt@odoo.com>2018-06-22 09:18:51 +0200
committerGitHub <noreply@github.com>2018-06-22 09:18:51 +0200
commit9ddf2c693282d28f996df8d665ca5b63f2fc107c (patch)
tree3be57f4648516c98928b7c57528dc9d69b1b9201 /addons
parentf557f34b75b19b5c25e259e4cbacd729fec6c240 (diff)
[FIX] crm: reset dashboard_graph_model on uninstall
Before this commit: * Install `sale_management`, `crm` * Uninstall `crm` * Go to sales -> sales channels * Boom! The view is broken This happens because both CRM and Sales share the sales teams view, yet CRM's override of the model adds a selection_add to the dashboard_graph_model selection field, when it is uninstalled, records whose dashboard_graph_model field are set to one of the values introduced by CRM keep this no-longer-valid value and upon accessing the view it crashes. This is a known limitation of selection fields and the selection_add feature. To solve this, an uninstallation hook has been created for CRM which will fetch all records whose dashboard_graph_model is set to `crm.opportunity.report`, and update the field of all these records to None (NULL). Fixes #25363
Diffstat (limited to 'addons')
-rw-r--r--addons/crm/__init__.py8
-rw-r--r--addons/crm/__manifest__.py1
2 files changed, 9 insertions, 0 deletions
diff --git a/addons/crm/__init__.py b/addons/crm/__init__.py
index 4e9b019bd7a..3398a4b470d 100644
--- a/addons/crm/__init__.py
+++ b/addons/crm/__init__.py
@@ -5,3 +5,11 @@ from . import controllers
from . import models
from . import report
from . import wizard
+
+from odoo import api, SUPERUSER_ID
+
+
+def uninstall_hook(cr, registry):
+ env = api.Environment(cr, SUPERUSER_ID, {})
+ teams = env['crm.team'].search([('dashboard_graph_model', '=', 'crm.opportunity.report')])
+ teams.update({'dashboard_graph_model': None})
diff --git a/addons/crm/__manifest__.py b/addons/crm/__manifest__.py
index a2e8745475a..5845bd582d1 100644
--- a/addons/crm/__manifest__.py
+++ b/addons/crm/__manifest__.py
@@ -57,4 +57,5 @@
'installable': True,
'application': True,
'auto_install': False,
+ 'uninstall_hook': 'uninstall_hook',
}