summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorqdp-odoo <qdp@odoo.com>2015-09-07 17:12:43 +0200
committerqdp-odoo <qdp@odoo.com>2015-09-07 17:12:46 +0200
commit108e424baf0d09c522668a9ed9261530e1216d04 (patch)
treebde23cea2a334ce669a6fc0efbd4d7216b48e33b /addons
parent3bf8e5970ffe0994956f821e349603c5a7dbc4e2 (diff)
[IMP] account: auto_install localization module(s) if the country is known
Diffstat (limited to 'addons')
-rw-r--r--addons/account/__init__.py21
-rw-r--r--addons/account/__openerp__.py1
2 files changed, 22 insertions, 0 deletions
diff --git a/addons/account/__init__.py b/addons/account/__init__.py
index 1c0b2504154..e1e75bd53ad 100644
--- a/addons/account/__init__.py
+++ b/addons/account/__init__.py
@@ -5,3 +5,24 @@ import models
import wizard
import report
+from openerp import SUPERUSER_ID
+
+def _auto_install_l10n(cr, registry):
+ #check the country of the main company (only) and eventually load some module needed in that country
+ country_code = registry['res.users'].browse(cr, SUPERUSER_ID, SUPERUSER_ID, {}).company_id.country_id.code
+ if country_code:
+ #auto install localization module(s) if available
+ module_list = []
+ if country_code in ['BJ', 'BF', 'CM', 'CF', 'KM', 'CG', 'CI', 'GA', 'GN', 'GW', 'GQ', 'ML', 'NE', 'CD', 'SN', 'TD', 'TG']:
+ #countries using OHADA Chart of Accounts
+ module_list.append('l10n_syscohada')
+ else:
+ module_list.append('l10n_' + country_code.lower())
+ if country_code == 'US':
+ module_list.append('account_plaid')
+ if country_code in ['US', 'AU', 'NZ']:
+ module_list.append('account_yodlee')
+
+ module_ids = registry['ir.module.module'].search(cr, SUPERUSER_ID, [('name', 'in', module_list), ('state', '=', 'uninstalled')])
+ registry['ir.module.module'].button_install(cr, SUPERUSER_ID, module_ids, {})
+
diff --git a/addons/account/__openerp__.py b/addons/account/__openerp__.py
index d14c8db70ff..e117b31346d 100644
--- a/addons/account/__openerp__.py
+++ b/addons/account/__openerp__.py
@@ -60,4 +60,5 @@ You could use this simplified accounting in case you work with an (external) acc
'installable': True,
'application': True,
'auto_install': False,
+ 'post_init_hook': '_auto_install_l10n',
}