Skip to content

Commit

Permalink
Merge 9c7dfa4 into bf96d2c
Browse files Browse the repository at this point in the history
  • Loading branch information
Arturo Flores committed Sep 19, 2018
2 parents bf96d2c + 9c7dfa4 commit cb9ecba
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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', r'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 cb9ecba

Please sign in to comment.