Skip to content

Commit

Permalink
[IMP] company_country: Process list of modules to install for checkin…
Browse files Browse the repository at this point in the history
…g if there is a l10n_ listed (#142)
  • Loading branch information
Arturo Flores authored and moylop260 committed Oct 31, 2018
1 parent 637bc30 commit 5b80fde
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
11 changes: 11 additions & 0 deletions company_country/README.rst
Expand Up @@ -23,6 +23,17 @@ To configure this module, you need to:

#. Set the environment variable COUNTRY using 2 letter of ISO 3166 codes.

Odoo-sh
=======

In case you need to configure odoo-sh:

- Go to your project
- Under settings go to **Module installation**
- Write down the modules you want to install, but make sure the localization is in that line along with the module you want to install

.. image:: https://user-images.githubusercontent.com/4094256/45762860-ef89cd00-bbf4-11e8-9902-9421b4163e81.png

Usage
=====

Expand Down
12 changes: 9 additions & 3 deletions company_country/models/res_config.py
Expand Up @@ -18,9 +18,15 @@ def load_country_company(self, country_code=None):
self.env.ref('base.main_company').write({'country_id': None})
return
if not country_code:
raise ValidationError(
_('Error COUNTRY environment variable with country code'
' not defined'))
l10n_to_install = self.env['ir.module.module'].search([
('state', '=', 'to install'),
('name', '=like', 'l10n_%')], limit=1)
if not l10n_to_install:
raise ValidationError(
_('Error COUNTRY environment variable with country code '
'not defined and no localization found in pool.'))
country_code = l10n_to_install.name.split('l10n_')[1][:2].upper()

country = self.env['res.country'].search([
('code', 'ilike', country_code)], limit=1)
if not country:
Expand Down

0 comments on commit 5b80fde

Please sign in to comment.