Skip to content

Commit

Permalink
Merge e6b0e98 into c1374f5
Browse files Browse the repository at this point in the history
  • Loading branch information
moylop260 committed Nov 12, 2019
2 parents c1374f5 + e6b0e98 commit da1c834
Show file tree
Hide file tree
Showing 16 changed files with 700 additions and 0 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ addons:
env:
global:
- VERSION="12.0" TESTS="0" LINT_CHECK="0" MAKEPOT="0"
- COUNTRY="US"

matrix:
- LINT_CHECK="1"
Expand Down
114 changes: 114 additions & 0 deletions company_country/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
===============
Company Country
===============

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github
:target: https://github.com/OCA/server-tools/tree/12.0/company_country
:alt: OCA/server-tools
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/server-tools-12-0/server-tools-12-0-company_country
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/149/12.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|

This module allow set a country to main company in order to use the hook of
account that install l10n_** based on country of main company.

**Table of contents**

.. contents::
:local:

Installation
============

To install this module, you need to:

#. Add as depends from your main module.

Configuration
=============

To configure this module, you need to:

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

Usage
=====

To use this module, you need to:

#. Just start server installing your main module.

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/149/12.0

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-tools/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/server-tools/issues/new?body=module:%20company_country%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Vauxoo

Contributors
~~~~~~~~~~~~

* Moisés López <moylop260@vauxoo.com>


Other credits
~~~~~~~~~~~~~

Vauxoo


Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

.. |maintainer-moylop260| image:: https://github.com/moylop260.png?size=40px
:target: https://github.com/moylop260
:alt: moylop260

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-moylop260|

This module is part of the `OCA/server-tools <https://github.com/OCA/server-tools/tree/12.0/company_country>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 4 additions & 0 deletions company_country/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2016 Vauxoo
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import models
from . import tests
17 changes: 17 additions & 0 deletions company_country/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# © 2016 Vauxoo (<http://www.vauxoo.com/>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Company Country",
"summary": "Set country to main company",
"version": "12.0.1.0.0",
"category": "base",
"website": "https://github.com/OCA/server-tools/tree/12.0/company_country",
"maintainers": ['moylop260'],
"author": "Vauxoo, Odoo Community Association (OCA)",
"license": "AGPL-3",
"depends": [],
"data": ['data/res_config.xml'],
"sequence": 1,
"auto_install": False,
"installable": True,
}
6 changes: 6 additions & 0 deletions company_country/data/res_config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?>
<odoo noupdate="1">

<function name="load_company_country" model="company.country.config.settings"/>

</odoo>
3 changes: 3 additions & 0 deletions company_country/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Copyright 2016 Vauxoo
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import res_config
35 changes: 35 additions & 0 deletions company_country/models/res_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright 2016 Vauxoo
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
import os

from odoo import _, api, models
from odoo.exceptions import ValidationError


class CompanyCountryConfigSettings(models.TransientModel):
_name = 'company.country.config.settings'
_description = 'Company Country Configuration Settings'

@api.model
def load_company_country(self, country_code=None):
if not country_code:
country_code = os.environ.get('COUNTRY')
if country_code == "":
self.env.ref('base.main_company').write({'country_id': None})
return
if not country_code:
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:
raise ValidationError(
_('Country code %s not found. Use ISO 3166 codes 2 letters'))
self.env.ref('base.main_company').write({'country_id': country.id})
3 changes: 3 additions & 0 deletions company_country/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
To configure this module, you need to:

#. Set the environment variable COUNTRY using 2 letter of ISO 3166 codes.
2 changes: 2 additions & 0 deletions company_country/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* Moisés López <moylop260@vauxoo.com>

2 changes: 2 additions & 0 deletions company_country/readme/CREDITS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Vauxoo

2 changes: 2 additions & 0 deletions company_country/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This module allow set a country to main company in order to use the hook of
account that install l10n_** based on country of main company.
3 changes: 3 additions & 0 deletions company_country/readme/INSTALL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
To install this module, you need to:

#. Add as depends from your main module.
7 changes: 7 additions & 0 deletions company_country/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
To use this module, you need to:

#. Just start server installing your main module.

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/149/12.0
Loading

0 comments on commit da1c834

Please sign in to comment.