From 70329177713131d3d6ec424137cad3702e9d38ae Mon Sep 17 00:00:00 2001 From: Yan Victor Date: Fri, 15 Sep 2023 05:44:19 -0300 Subject: [PATCH] [IMP] account: Avatax module installation Auto install AvaTax module for countries that use AvaTax ('US','BR'). Add a checkbox in settings to easily install the module if needed task ID: 3398637 closes odoo/odoo#136490 Related: odoo/enterprise#47979 Signed-off-by: Quentin De Paoli --- addons/account/__init__.py | 13 +++++++++++++ addons/account/models/res_config_settings.py | 1 + addons/account/views/res_config_settings_views.xml | 4 ++++ 3 files changed, 18 insertions(+) diff --git a/addons/account/__init__.py b/addons/account/__init__.py index 9b8f0407ee4..fb50e4eb5c4 100644 --- a/addons/account/__init__.py +++ b/addons/account/__init__.py @@ -35,9 +35,22 @@ def _auto_install_l10n(env): if module_ids: module_ids.sudo().button_install() +def _auto_install_avatax(env): + """ Install the avatax module automatically if the company is in a country that uses avatax """ + avatax_country_codes = ['US', 'BR'] + + country = env.company.country_id + country_code = country.code + + if country_code in avatax_country_codes: + module = env['ir.module.module'].search([('name', '=', 'account_avatax')]) + if module.state == 'uninstalled': + module.sudo().button_install() + def _account_post_init(env): _auto_install_l10n(env) _set_fiscal_country(env) + _auto_install_avatax(env) # imported here to avoid dependency cycle issues # pylint: disable=wrong-import-position diff --git a/addons/account/models/res_config_settings.py b/addons/account/models/res_config_settings.py index ba475a44ef0..36be090c539 100644 --- a/addons/account/models/res_config_settings.py +++ b/addons/account/models/res_config_settings.py @@ -114,6 +114,7 @@ class ResConfigSettings(models.TransientModel): module_product_margin = fields.Boolean(string="Allow Product Margin") module_l10n_eu_oss = fields.Boolean(string="EU Intra-community Distance Selling") module_account_taxcloud = fields.Boolean(string="Account TaxCloud") + module_account_avatax = fields.Boolean(string="Account Avatax") module_account_invoice_extract = fields.Boolean(string="Document Digitization") module_snailmail_account = fields.Boolean(string="Snailmail") tax_exigibility = fields.Boolean(string='Cash Basis', related='company_id.tax_exigibility', readonly=False) diff --git a/addons/account/views/res_config_settings_views.xml b/addons/account/views/res_config_settings_views.xml index 43ef1f1754f..8c6dbe3acf4 100644 --- a/addons/account/views/res_config_settings_views.xml +++ b/addons/account/views/res_config_settings_views.xml @@ -62,6 +62,10 @@ documentation="/applications/finance/accounting/taxation/taxes/taxcloud.html"> + + +