summaryrefslogtreecommitdiff
path: root/addons/account_tax_python
diff options
context:
space:
mode:
authorVictor Feyens <vfe@odoo.com>2020-02-13 12:55:57 +0000
committerVictor Feyens <vfe@odoo.com>2020-02-13 16:52:56 +0000
commit6f1283ce7e537f8da0291d4c19872a401952b229 (patch)
tree7a07b5768cb6708169c62f7a61c0569ac81c5c3f /addons/account_tax_python
parentc0728dbfff126aaf12a04e49ea846653e2406350 (diff)
[FIX] account_tax_python: uninstall
When some existing taxes are defined with amount_type = "code", the module uninstallation will leave the current data inconsistent. Add an uninstall hook archiving the given taxes, logging the problematic records ids. Fixes #45240 closes odoo/odoo#45338 X-original-commit: 16e000b5dcc93a3c90a7d1b6d9d9a6097d5a9849 Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
Diffstat (limited to 'addons/account_tax_python')
-rw-r--r--addons/account_tax_python/__init__.py13
-rw-r--r--addons/account_tax_python/__manifest__.py1
2 files changed, 14 insertions, 0 deletions
diff --git a/addons/account_tax_python/__init__.py b/addons/account_tax_python/__init__.py
index dc5e6b693d1..3b46f4dba2b 100644
--- a/addons/account_tax_python/__init__.py
+++ b/addons/account_tax_python/__init__.py
@@ -2,3 +2,16 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import models
+
+from odoo import api, SUPERUSER_ID
+
+import logging
+_logger = logging.getLogger(__name__)
+
+def uninstall_hook(cr, registry):
+ env = api.Environment(cr, SUPERUSER_ID, {})
+
+ code_taxes = env['account.tax'].search([('amount_type', '=', 'code')])
+ code_taxes.write({'amount_type': 'percent', 'active': False})
+
+ _logger.warning("The following taxes have been archived following 'account_tax_python' module uninstallation: %s" % code_taxes.ids)
diff --git a/addons/account_tax_python/__manifest__.py b/addons/account_tax_python/__manifest__.py
index e27facde6aa..cb0dde674a5 100644
--- a/addons/account_tax_python/__manifest__.py
+++ b/addons/account_tax_python/__manifest__.py
@@ -17,4 +17,5 @@ A tax defined as python code consists of two snippets of python code which are e
'data': [
'views/account_tax_views.xml',
],
+ 'uninstall_hook': "uninstall_hook",
}