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>
18 lines
573 B
Python
18 lines
573 B
Python
# -*- coding: utf-8 -*-
|
|
# 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)
|