diff options
Diffstat (limited to 'addons/account_tax_python')
| -rw-r--r-- | addons/account_tax_python/__init__.py | 13 | ||||
| -rw-r--r-- | addons/account_tax_python/__manifest__.py | 1 | ||||
| -rw-r--r-- | addons/account_tax_python/models/account_tax.py | 8 |
3 files changed, 6 insertions, 16 deletions
diff --git a/addons/account_tax_python/__init__.py b/addons/account_tax_python/__init__.py index 3b46f4dba2b..dc5e6b693d1 100644 --- a/addons/account_tax_python/__init__.py +++ b/addons/account_tax_python/__init__.py @@ -2,16 +2,3 @@ # 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 cb0dde674a5..e27facde6aa 100644 --- a/addons/account_tax_python/__manifest__.py +++ b/addons/account_tax_python/__manifest__.py @@ -17,5 +17,4 @@ 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", } diff --git a/addons/account_tax_python/models/account_tax.py b/addons/account_tax_python/models/account_tax.py index dbd143a58b5..435be47fa9c 100644 --- a/addons/account_tax_python/models/account_tax.py +++ b/addons/account_tax_python/models/account_tax.py @@ -8,7 +8,9 @@ from odoo.tools.safe_eval import safe_eval class AccountTaxPython(models.Model): _inherit = "account.tax" - amount_type = fields.Selection(selection_add=[('code', 'Python Code')]) + amount_type = fields.Selection(selection_add=[ + ('code', 'Python Code') + ], ondelete={'code': lambda recs: recs.write({'amount_type': 'percent', 'active': False})}) python_compute = fields.Text(string='Python Code', default="result = price_unit * 0.10", help="Compute the amount of the tax by setting the variable 'result'.\n\n" @@ -54,7 +56,9 @@ class AccountTaxPython(models.Model): class AccountTaxTemplatePython(models.Model): _inherit = 'account.tax.template' - amount_type = fields.Selection(selection_add=[('code', 'Python Code')]) + amount_type = fields.Selection(selection_add=[ + ('code', 'Python Code') + ], ondelete={'code': 'cascade'}) python_compute = fields.Text(string='Python Code', default="result = price_unit * 0.10", help="Compute the amount of the tax by setting the variable 'result'.\n\n" |
