Skip to content

Commit

Permalink
[MIG]l10n_fr_department_oversea: migrate to 11.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Danh Võ Phương authored and legalsylvain committed May 13, 2018
1 parent 3f64143 commit 48469f8
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 110 deletions.
5 changes: 3 additions & 2 deletions l10n_fr_department_oversea/README.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:target: https://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3

===========================================================================
Expand All @@ -13,7 +13,7 @@ Usage

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


Bug Tracker
Expand All @@ -31,6 +31,7 @@ Contributors
------------

* Alexis de Lattre <alexis.delattre@akretion.com>
* Danh Vo <https://github.com/danhvophuong>

Maintainer
----------
Expand Down
2 changes: 0 additions & 2 deletions l10n_fr_department_oversea/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
# -*- coding: utf-8 -*-

from .post_install import set_oversea_department_on_partner
11 changes: 5 additions & 6 deletions l10n_fr_department_oversea/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
# -*- coding: utf-8 -*-
# © 2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
'name': 'French Overseas Departments (DOM)',
'summary': u"Populate Database with overseas French "
u"Departments (Départements d'outre-mer)",
'version': '10.0.1.0.0',
'summary': 'Populate Database with overseas French '
"Departments (Départements d'outre-mer)",
'version': '11.0.1.0.0',
'category': 'French Localization',
'author': "Akretion,Odoo Community Association (OCA)",
'author': 'Akretion,Odoo Community Association (OCA)',
'website': 'http://www.akretion.com',
'license': 'AGPL-3',
'depends': ['l10n_fr_department'],
Expand Down
69 changes: 31 additions & 38 deletions l10n_fr_department_oversea/data/res_country_department.xml
Original file line number Diff line number Diff line change
@@ -1,42 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
© 2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
-->
<odoo>
<data noupdate="1">


<record id="res_country_department_guadeloupe" model="res.country.department">
<field name="name">Guadeloupe</field>
<field name="code">971</field>
<field name="state_id" ref="res_country_state_guadeloupe"/>
</record>

<record id="res_country_department_martinique" model="res.country.department">
<field name="name">Martinique</field>
<field name="code">972</field>
<field name="state_id" ref="res_country_state_martinique"/>
</record>

<record id="res_country_department_guyane" model="res.country.department">
<field name="name">Guyane</field>
<field name="code">973</field>
<field name="state_id" ref="res_country_state_guyane"/>
</record>

<record id="res_country_department_reunion" model="res.country.department">
<field name="name">La Réunion</field>
<field name="code">974</field>
<field name="state_id" ref="res_country_state_reunion"/>
</record>

<record id="res_country_department_mayotte" model="res.country.department">
<field name="name">Mayotte</field>
<field name="code">976</field>
<field name="state_id" ref="res_country_state_mayotte"/>
</record>


</data>
<odoo noupdate="1">
<record id="res_country_department_guadeloupe" model="res.country.department">
<field name="name">Guadeloupe</field>
<field name="code">971</field>
<field name="state_id" ref="res_country_state_guadeloupe"/>
</record>

<record id="res_country_department_martinique" model="res.country.department">
<field name="name">Martinique</field>
<field name="code">972</field>
<field name="state_id" ref="res_country_state_martinique"/>
</record>

<record id="res_country_department_guyane" model="res.country.department">
<field name="name">Guyane</field>
<field name="code">973</field>
<field name="state_id" ref="res_country_state_guyane"/>
</record>

<record id="res_country_department_reunion" model="res.country.department">
<field name="name">La Réunion</field>
<field name="code">974</field>
<field name="state_id" ref="res_country_state_reunion"/>
</record>

<record id="res_country_department_mayotte" model="res.country.department">
<field name="name">Mayotte</field>
<field name="code">976</field>
<field name="state_id" ref="res_country_state_mayotte"/>
</record>
</odoo>
69 changes: 31 additions & 38 deletions l10n_fr_department_oversea/data/res_country_state.xml
Original file line number Diff line number Diff line change
@@ -1,42 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
© 2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
-->
<odoo>
<data noupdate="1">


<record id="res_country_state_guadeloupe" model="res.country.state">
<field name="code">GP</field>
<field name="country_id" ref="base.gp"/>
<field name="name">Guadeloupe</field>
</record>

<record id="res_country_state_martinique" model="res.country.state">
<field name="code">MQ</field>
<field name="country_id" ref="base.mq"/>
<field name="name">Martinique</field>
</record>

<record id="res_country_state_guyane" model="res.country.state">
<field name="code">GF</field>
<field name="country_id" ref="base.gf"/>
<field name="name">Guyane</field>
</record>

<record id="res_country_state_reunion" model="res.country.state">
<field name="code">RE</field>
<field name="country_id" ref="base.re"/>
<field name="name">La Réunion</field>
</record>

<record id="res_country_state_mayotte" model="res.country.state">
<field name="code">YT</field>
<field name="country_id" ref="base.yt"/>
<field name="name">Mayotte</field>
</record>


</data>
<odoo noupdate="1">
<record id="res_country_state_guadeloupe" model="res.country.state">
<field name="code">GP</field>
<field name="country_id" ref="base.gp"/>
<field name="name">Guadeloupe</field>
</record>

<record id="res_country_state_martinique" model="res.country.state">
<field name="code">MQ</field>
<field name="country_id" ref="base.mq"/>
<field name="name">Martinique</field>
</record>

<record id="res_country_state_guyane" model="res.country.state">
<field name="code">GF</field>
<field name="country_id" ref="base.gf"/>
<field name="name">Guyane</field>
</record>

<record id="res_country_state_reunion" model="res.country.state">
<field name="code">RE</field>
<field name="country_id" ref="base.re"/>
<field name="name">La Réunion</field>
</record>

<record id="res_country_state_mayotte" model="res.country.state">
<field name="code">YT</field>
<field name="country_id" ref="base.yt"/>
<field name="name">Mayotte</field>
</record>
</odoo>
14 changes: 6 additions & 8 deletions l10n_fr_department_oversea/post_install.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
# © 2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, SUPERUSER_ID

Expand All @@ -16,11 +15,10 @@ def set_oversea_department_on_partner(cr, registry):
env = api.Environment(cr, SUPERUSER_ID, {})
fr_countries = env['res.country'].search(
[('code', 'in', ('FR', 'GP', 'MQ', 'GF', 'RE', 'YT'))])
partners = env['res.partner'].search(
[
'|', ('active', '=', False), ('active', '=', True),
('country_id', 'in', fr_countries.ids),
('department_id', '=', False),
])
partners = env['res.partner'].search([
'|', ('active', '=', False), ('active', '=', True),
('country_id', 'in', fr_countries.ids),
('department_id', '=', False)
])
partners._compute_department()
return
2 changes: 0 additions & 2 deletions l10n_fr_department_oversea/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
# -*- coding: utf-8 -*-

from . import test_department_oversea
25 changes: 11 additions & 14 deletions l10n_fr_department_oversea/tests/test_department_oversea.py
Original file line number Diff line number Diff line change
@@ -1,36 +1,33 @@
# -*- coding: utf-8 -*-
# © 2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo.tests.common import TransactionCase


class TestFrDepartmentOversea(TransactionCase):

def test_fr_department_oversea(self):
rpo = self.env['res.partner']
partner1 = rpo.create({
'name': u'Monsieur Payet',
'street': u'11 rue du Stade',
'street2': u'Montgaillard',
'name': 'Monsieur Payet',
'street': '11 rue du Stade',
'street2': 'Montgaillard',
'zip': '97400',
'city': u'Saint Denis',
'city': 'Saint Denis',
'country_id': self.env.ref('base.re').id,
})
self.assertEquals(
self.assertEqual(
partner1.department_id,
self.env.ref(
'l10n_fr_department_oversea.res_country_department_reunion'))
# I also want it to work if you select France as country
partner2 = rpo.create({
'name': u'Monsieur Hoarau',
'street': u'13 rue du Stade',
'street2': u'Montgaillard',
'name': 'Monsieur Hoarau',
'street': '13 rue du Stade',
'street2': 'Montgaillard',
'zip': '97400',
'city': u'Saint Denis',
'city': 'Saint Denis',
'country_id': self.env.ref('base.fr').id,
})
self.assertEquals(
self.assertEqual(
partner2.department_id,
self.env.ref(
'l10n_fr_department_oversea.res_country_department_reunion'))

0 comments on commit 48469f8

Please sign in to comment.