-
-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by alexis-via
- Loading branch information
Showing
13 changed files
with
848 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
======================= | ||
French States (Régions) | ||
======================= | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:573c0598b59f23178241b44edcc301b488a34eaa0f0eb6d9e839e4c29612101a | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |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%2Fl10n--france-lightgray.png?logo=github | ||
:target: https://github.com/OCA/l10n-france/tree/18.0/l10n_fr_state | ||
:alt: OCA/l10n-france | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/l10n-france-18-0/l10n-france-18-0-l10n_fr_state | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png | ||
:target: https://runboat.odoo-community.org/builds?repo=OCA/l10n-france&target_branch=18.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This module populate the table *res_country_state* with the french | ||
states (*Régions françaises*), but only the french states of mainland. | ||
If you need the overseas states, please install the module | ||
*l10n_fr_department_oversea*. | ||
|
||
In the past, the module was using 3166-2:FR codifications without | ||
country prefix (more detail on | ||
`Wikipedia <http://fr.wikipedia.org/wiki/ISO_3166-2:FR>`__), but | ||
unfortunately this codification hasn't been updated since 2013, so we | ||
can't use it with the new organisation of regions that was introduced on | ||
January 1st 2016. So we switched to the INSEE codification, cf | ||
`Wikipedia | ||
(Codes_géographiques_de_la_France) <https://fr.wikipedia.org/wiki/Codes_g%C3%A9ographiques_de_la_France>`__ | ||
; by the way, this codification is also used by | ||
`geonames.org <http://www.geonames.org/>`__. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/l10n-france/issues>`_. | ||
In case of trouble, please check there if your issue has already been reported. | ||
If you spotted it first, help us to smash it by providing a detailed and welcomed | ||
`feedback <https://github.com/OCA/l10n-france/issues/new?body=module:%20l10n_fr_state%0Aversion:%2018.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 | ||
------- | ||
|
||
* GRAP | ||
* Akretion | ||
* Nicolas JEUDY | ||
|
||
Contributors | ||
------------ | ||
|
||
- Sylvain LE GAL (`Twitter <https://twitter.com/legalsylvain>`__), GRAP | ||
(Groupement Régional Alimentaire de Proximité) | ||
- Alexis de Lattre <alexis.delattre@akretion.com> | ||
- Nicolas JEUDY <https://github.com/njeudy> | ||
|
||
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-legalsylvain| image:: https://github.com/legalsylvain.png?size=40px | ||
:target: https://github.com/legalsylvain | ||
:alt: legalsylvain | ||
.. |maintainer-alexis-via| image:: https://github.com/alexis-via.png?size=40px | ||
:target: https://github.com/alexis-via | ||
:alt: alexis-via | ||
|
||
Current `maintainers <https://odoo-community.org/page/maintainer-role>`__: | ||
|
||
|maintainer-legalsylvain| |maintainer-alexis-via| | ||
|
||
This module is part of the `OCA/l10n-france <https://github.com/OCA/l10n-france/tree/18.0/l10n_fr_state>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .pre_init_hook import create_fr_state_xmlid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Copyright 2013-2022 GRAP (Sylvain LE GAL https://twitter.com/legalsylvain) | ||
# Copyright 2015-2022 Akretion France | ||
# @author: Alexis de Lattre <alexis.delattre@akretion.com> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
"name": "French States (Régions)", | ||
"summary": "Populate Database with French States (Régions)", | ||
"version": "18.0.1.0.0", | ||
"category": "French Localization", | ||
"author": "GRAP, " | ||
"Akretion, " | ||
"Nicolas JEUDY, " | ||
"Odoo Community Association (OCA)", | ||
"maintainers": ["legalsylvain", "alexis-via"], | ||
"website": "https://github.com/OCA/l10n-france", | ||
"license": "AGPL-3", | ||
"depends": ["base"], | ||
"pre_init_hook": "create_fr_state_xmlid", | ||
"data": ["data/res_country_state.xml"], | ||
"images": ["static/src/img/screenshots/1.png"], | ||
"installable": True, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<!-- | ||
Copyright 2013-2022 GRAP (Sylvain LE GAL https://twitter.com/legalsylvain) | ||
Copyright 2016-2022 Akretion France (http://www.akretion.com/) | ||
@author: Alexis de Lattre <alexis.delattre@akretion.com> | ||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
--> | ||
<odoo noupdate="1"> | ||
<!-- ex Alsace-Champagne-Ardenne-Lorraine --> | ||
<record id="res_country_state_alsace" model="res.country.state"> | ||
<field name="name">Grand Est</field> | ||
<field name="code">44</field> | ||
<field name="country_id" ref="base.fr" /> | ||
</record> | ||
<!-- ex Aquitaine-Limousin-Poitou-Charentes --> | ||
<record id="res_country_state_aquitaine" model="res.country.state"> | ||
<field name="name">Nouvelle-Aquitaine</field> | ||
<field name="code">75</field> | ||
<field name="country_id" ref="base.fr" /> | ||
</record> | ||
<record id="res_country_state_auvergne" model="res.country.state"> | ||
<field name="name">Auvergne-Rhône-Alpes</field> | ||
<field name="code">84</field> | ||
<field name="country_id" ref="base.fr" /> | ||
</record> | ||
<record id="res_country_state_bourgogne" model="res.country.state"> | ||
<field name="name">Bourgogne-Franche-Comté</field> | ||
<field name="code">27</field> | ||
<field name="country_id" ref="base.fr" /> | ||
</record> | ||
<record id="res_country_state_bretagne" model="res.country.state"> | ||
<field name="name">Bretagne</field> | ||
<field name="code">53</field> | ||
<field name="country_id" ref="base.fr" /> | ||
</record> | ||
<record id="res_country_state_centre" model="res.country.state"> | ||
<field name="name">Centre-Val de Loire</field> | ||
<field name="code">24</field> | ||
<field name="country_id" ref="base.fr" /> | ||
</record> | ||
<record id="res_country_state_corse" model="res.country.state"> | ||
<field name="name">Corse</field> | ||
<field name="code">94</field> | ||
<field name="country_id" ref="base.fr" /> | ||
</record> | ||
<record id="res_country_state_iledefrance" model="res.country.state"> | ||
<field name="name">Île-de-France</field> | ||
<field name="code">11</field> | ||
<field name="country_id" ref="base.fr" /> | ||
</record> | ||
<!-- ex Languedoc-Roussillon-Midi-Pyrénées --> | ||
<record id="res_country_state_languedocroussillon" model="res.country.state"> | ||
<field name="name">Occitanie</field> | ||
<field name="code">76</field> | ||
<field name="country_id" ref="base.fr" /> | ||
</record> | ||
<!-- ex Nord-Pas-de-Calais-Picardie --> | ||
<record id="res_country_state_nordpasdecalais" model="res.country.state"> | ||
<field name="name">Hauts-de-France</field> | ||
<field name="code">32</field> | ||
<field name="country_id" ref="base.fr" /> | ||
</record> | ||
<record id="res_country_state_bassenormandie" model="res.country.state"> | ||
<field name="name">Normandie</field> | ||
<field name="code">28</field> | ||
<field name="country_id" ref="base.fr" /> | ||
</record> | ||
<record id="res_country_state_paysdelaloire" model="res.country.state"> | ||
<field name="name">Pays de la Loire</field> | ||
<field name="code">52</field> | ||
<field name="country_id" ref="base.fr" /> | ||
</record> | ||
<record id="res_country_state_provencealpescotedazur" model="res.country.state"> | ||
<field name="name">Provence-Alpes-Côte d'Azur</field> | ||
<field name="code">93</field> | ||
<field name="country_id" ref="base.fr" /> | ||
</record> | ||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
# ############################################################################# | ||
# | ||
# l10n FR States module for OpenERP | ||
# Copyright (C) 2013-2014 GRAP (http://www.grap.coop) | ||
# @author Sylvain LE GAL (https://twitter.com/legalsylvain) | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as | ||
# published by the Free Software Foundation, either version 3 of the | ||
# License, or (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
# ############################################################################# | ||
# Translation of OpenERP Server. | ||
# This file contains the translation of the following modules: | ||
# * l10n_fr_state | ||
# * base | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: OpenERP Server 7.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2014-03-26 16:08+0000\n" | ||
"PO-Revision-Date: 2014-03-26 16:08+0000\n" | ||
"Last-Translator: <>\n" | ||
"Language-Team: \n" | ||
"Language: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: \n" | ||
|
||
#~ msgid "Country state" | ||
#~ msgstr "Région" | ||
|
||
#~ msgid "State Name" | ||
#~ msgstr "Nom de la région" | ||
|
||
#~ msgid "State Code" | ||
#~ msgstr "Code de la région" | ||
|
||
#~ msgid "French States (Région)" | ||
#~ msgstr "Régions Françaises" | ||
|
||
#~ msgid "Populate Database with French States (Région)" | ||
#~ msgstr "Remplit la base de données avec les régions françaises" | ||
|
||
#~ msgid "" | ||
#~ "\n" | ||
#~ "Populate Database with French States (Région)\n" | ||
#~ "=============================================\n" | ||
#~ "\n" | ||
#~ "Feature:\n" | ||
#~ "--------\n" | ||
#~ " * Populate the table res_country_state with the french states. (named " | ||
#~ "'Région')\n" | ||
#~ "\n" | ||
#~ "Technical information:\n" | ||
#~ "----------------------\n" | ||
#~ " * Use 3166-2:FR codifications (more detail http://fr.wikipedia.org/" | ||
#~ "wiki/ISO_3166-2:FR);\n" | ||
#~ " * Only populate inner states; (no Guyane, Mayotte, etc...) because " | ||
#~ "there are in the res_country table;\n" | ||
#~ " * Change res_country_state.code size. (3 to 4);\n" | ||
#~ "\n" | ||
#~ "Copyright, Authors and Licence:\n" | ||
#~ "-------------------------------\n" | ||
#~ " * Copyright: 2013-2014, GRAP, Groupement Régional Alimentaire de " | ||
#~ "Proximité;\n" | ||
#~ " * Author: Sylvain LE GAL (https://twitter.com/legalsylvain);\n" | ||
#~ " * Licence: AGPL-3 (http://www.gnu.org/licenses/);" | ||
#~ msgstr "" | ||
#~ "\n" | ||
#~ "Remplit la base de données avec les régions françaises\n" | ||
#~ "======================================================\n" | ||
#~ "\n" | ||
#~ "Caractéristique :\n" | ||
#~ "-----------------\n" | ||
#~ " * Remplit la table 'res_country_state' avec les régions françaises\n" | ||
#~ "\n" | ||
#~ "Informations techniques :\n" | ||
#~ "-------------------------\n" | ||
#~ " * Utilise la codification 3166-2:FR (plus de détail sur http://fr." | ||
#~ "wikipedia.org/wiki/ISO_3166-2:FR) ;\n" | ||
#~ " * Ne remplit que les régions métropolitaines (pas la Guyane, ni " | ||
#~ "Mayotte, etc...) car ces régions sont déjà présentes dans la table " | ||
#~ "'res_country' ;\n" | ||
#~ " * Modifie la taille du champs 'res_country_state.code'. (de 3 à 4 " | ||
#~ "caractères) ;\n" | ||
#~ "\n" | ||
#~ "Copyright, Auteurs et Licence:\n" | ||
#~ "------------------------------\n" | ||
#~ " * Copyright : 2013, Groupement Régional Alimentaire de Proximité ;\n" | ||
#~ " * Auteur : Sylvain LE GAL (https://twitter.com/legalsylvain) ;\n" | ||
#~ " * Licence : AGPL-3 (http://www.gnu.org/licenses/) ;" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 17.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"Last-Translator: \n" | ||
"Language-Team: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: \n" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Copyright 2017-2022 Akretion France | ||
# @author: Alexis de Lattre <alexis.delattre@akretion.com> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
import logging | ||
|
||
from lxml import etree | ||
|
||
from odoo.tools import file_open | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
# This code is designed to avoid a problem in the following scenario: | ||
# On a new database, the administrator executes these steps in this order: | ||
# 1) installs base_address_extended_geonames_import and run the geonames import wizard | ||
# for France | ||
# -> it creates all the French regions (without xmlid) | ||
# 2) installs l10n_fr_state | ||
# -> it tries to create the French regions, but it fails due to the unicity | ||
# constraint unique(country_id, code) of res.country.state. | ||
|
||
|
||
def create_fr_state_xmlid(env): | ||
generic_create_state_xmlid(env, "l10n_fr_state", "data/res_country_state.xml") | ||
|
||
|
||
def generic_create_state_xmlid(env, module_name, data_file): | ||
"""This method is also used by l10n_fr_state and l10n_fr_department_oversea""" | ||
with file_open(f"{module_name}/{data_file}", "rb") as f: | ||
xml_root = etree.parse(f) | ||
data = {} # key = xmlid, value = {"code": "GP", "country_id": "base.gp"} | ||
for record in xml_root.xpath("//record"): | ||
xmlid = record.attrib["id"] | ||
data[xmlid] = {} | ||
for xfield in record.xpath("field"): | ||
xfield_dict = xfield.attrib | ||
data[xmlid][xfield_dict["name"]] = xfield_dict.get("ref") or xfield.text | ||
logger.debug("generic_create_state_xmlid data=%s", data) | ||
for xmlid, state_data in data.items(): | ||
country_id = env.ref(state_data["country_id"]).id | ||
state = env["res.country.state"].search( | ||
[("code", "=", state_data["code"]), ("country_id", "=", country_id)], | ||
limit=1, | ||
) | ||
if state: | ||
env["ir.model.data"].create( | ||
{ | ||
"name": xmlid, | ||
"res_id": state.id, | ||
"module": module_name, | ||
"model": "res.country.state", | ||
} | ||
) | ||
logger.info( | ||
"XMLID %s.%s created for state %s code %s", | ||
module_name, | ||
xmlid, | ||
state.name, | ||
state.code, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[build-system] | ||
requires = ["whool"] | ||
build-backend = "whool.buildapi" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
- Sylvain LE GAL ([Twitter](https://twitter.com/legalsylvain)), GRAP | ||
(Groupement Régional Alimentaire de Proximité) | ||
- Alexis de Lattre \<<alexis.delattre@akretion.com>\> | ||
- Nicolas JEUDY \<<https://github.com/njeudy>\> |
Oops, something went wrong.