summaryrefslogtreecommitdiff
path: root/addons/account/__init__.py
diff options
context:
space:
mode:
authoroco-odoo <oco@odoo.com>2020-08-03 09:05:02 +0000
committeroco-odoo <oco@odoo.com>2020-08-14 07:59:16 +0000
commit07fbfbb5fb1a19821fe095e26db6fe48ebdf7aaf (patch)
tree6c8c0da98955ed836b0bb1fc9893e7f08e600c5c /addons/account/__init__.py
parent50abd90b38a97d3c401e7849004694aa87bcb3cc (diff)
[IMP] account: remove account_fiscal_country_* config parameter
This config parameter was used in order to choose another country than the company's to select the tax report. It is now replaced by a new account_tax_fiscal_country_id field in account_reports. closes odoo/odoo#55308 Related: odoo/enterprise#12156 Related: odoo/upgrade#1624 Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
Diffstat (limited to 'addons/account/__init__.py')
-rw-r--r--addons/account/__init__.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/addons/account/__init__.py b/addons/account/__init__.py
index 7b967482ed0..27c64772919 100644
--- a/addons/account/__init__.py
+++ b/addons/account/__init__.py
@@ -10,9 +10,17 @@ from odoo import api, SUPERUSER_ID
SYSCOHADA_LIST = ['BJ', 'BF', 'CM', 'CF', 'KM', 'CG', 'CI', 'GA', 'GN', 'GW', 'GQ', 'ML', 'NE', 'CD', 'SN', 'TD', 'TG']
-def _auto_install_l10n(cr, registry):
+def _set_fiscal_country(env):
+ """ Sets the fiscal country on existing companies when installing the module.
+ That field is an editable computed field. It doesn't automatically get computed
+ on existing records by the ORM when installing the module, so doing that by hand
+ ensures existing records will get a value for it if needed.
+ """
+ env['res.company'].search([]).compute_account_tax_fiscal_country()
+
+
+def _auto_install_l10n(env):
#check the country of the main company (only) and eventually load some module needed in that country
- env = api.Environment(cr, SUPERUSER_ID, {})
country_code = env.company.country_id.code
if country_code:
#auto install localization module(s) if available
@@ -63,3 +71,8 @@ def _auto_install_l10n(cr, registry):
module_list.append('account_bank_statement_import_camt')
module_ids = env['ir.module.module'].search([('name', 'in', module_list), ('state', '=', 'uninstalled')])
module_ids.sudo().button_install()
+
+def _account_post_init(cr, registry):
+ env = api.Environment(cr, SUPERUSER_ID, {})
+ _auto_install_l10n(env)
+ _set_fiscal_country(env)