diff options
Diffstat (limited to 'addons/account/__init__.py')
| -rw-r--r-- | addons/account/__init__.py | 17 |
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) |
