Skip to content
Permalink
Browse files

[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 #45306

X-original-commit: 16e000b
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
  • Loading branch information
Feyensv committed Feb 13, 2020
1 parent b7a4284 commit 26a856d7302edb14c22f007e308f6df691b87d23
Showing with 14 additions and 0 deletions.
  1. +13 −0 addons/account_tax_python/__init__.py
  2. +1 −0 addons/account_tax_python/__manifest__.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)
@@ -18,4 +18,5 @@
'data': [
'views/account_tax_views.xml',
],
'uninstall_hook': "uninstall_hook",
}

0 comments on commit 26a856d

Please sign in to comment.
You can’t perform that action at this time.