Skip to content

Commit

Permalink
Merge 1187ef6 into 246fafc
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Rijnhart (Therp) committed Aug 19, 2015
2 parents 246fafc + 1187ef6 commit 90f9547
Show file tree
Hide file tree
Showing 14 changed files with 453 additions and 0 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ install:
- git clone https://github.com/OCA/maintainer-quality-tools.git ${HOME}/maintainer-quality-tools
- export PATH=${HOME}/maintainer-quality-tools/travis:${PATH}
- travis_install_nightly
- pip install pypostcode
# example: dependency
# - git clone https://github.com/OCA/webkit-tools -b ${VERSION} $HOME/webkit-tools

Expand Down
75 changes: 75 additions & 0 deletions l10n_nl_postcodeapi/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:alt: License: AGPL-3

Auto-completion for Dutch addresses
===================================
This module contains integration of the excellent and free address completion
service 'PostcodeAPI'. The service allows lookups by zip code and house number,
providing street name and city. The lookups will be triggered in the partner
form views when a zip code or house number is entered or modified. Only
Dutch addresses (which is assumed to include addresses with no country) are
auto-completed.

More info about the lookup service here: http://www.postcodeapi.nu/

Installation
============
This module depends on the module partner_street_number, which will split
up the street field into separate fields for street name and number.

This module can be gotten from https://github.com/oca/partner-contact/tree/8.0

You also need to have the 'pyPostcode' Python library by Stefan Jansen
installed (https://pypi.python.org/pypi/pyPostcode).

Configuration
=============
Please enter the API key that you request from PostcodeAPI into the system
parameter 'l10n_nl_postcodeapi.apikey'

Provinces are autocompleted if a country state with the exact name is found in
the system. A CSV file with the Dutch provinces is included in the data
directory, but not loaded by default. You can import the file manually.

Compatibility
=============
This module is compatible with OpenERP 8.0.

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/176/8.0

.. repo_id is available in https://github.com/OCA/maintainer-tools/blob/master/tools/repos_with_ids.txt
.. branch is "8.0" for example
Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/l10n-netherlands/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
`here <https://github.com/OCA/l10n-netherlands/issues/new?body=module:%20l10n_nl_postcodeapi%0Aversion:%200.1%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Credits
=======

Contributors
------------

* Stefan Rijnhart (Therp BV) <stefan@therp.nl>

Maintainer
----------

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

This module is maintained by the OCA at https://github.com/OCA/l10n-netherlands

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.

To contribute to this module, please visit http://odoo-community.org.
1 change: 1 addition & 0 deletions l10n_nl_postcodeapi/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
37 changes: 37 additions & 0 deletions l10n_nl_postcodeapi/__openerp__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# This module copyright (C) 2013-2015 Therp BV (<http://therp.nl>).
#
# 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/>.
#
##############################################################################

{
'name': 'Integration with PostcodeApi.nu',
'summary': 'Autocomplete Dutch addresses using PostcodeApi.nu',
'version': '0.1',
'author': 'Therp BV',
'category': 'Localization',
'website': 'https://github.com/OCA/l10n-netherlands',
'license': 'AGPL-3',
'depends': ['partner_street_number'],
'data': [
'data/ir_config_parameter.xml',
],
"external_dependencies": {
'python': ['pyPostcode'],
}
}
11 changes: 11 additions & 0 deletions l10n_nl_postcodeapi/data/ir_config_parameter.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data noupdate="1">

<record id="parameter_apikey" model="ir.config_parameter">
<field name="key">l10n_nl_postcodeapi.apikey</field>
<field name="value">Your API key</field>
</record>

</data>
</openerp>
13 changes: 13 additions & 0 deletions l10n_nl_postcodeapi/data/res.country.state.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
id,country_id,name,code
,nl,Drenthe,DR
,nl,Flevoland,FL
,nl,Friesland,FR
,nl,Gelderland,GD
,nl,Groningen,GR
,nl,Limburg,LB
,nl,Noord-Brabant,NB
,nl,Noord-Holland,NH
,nl,Overijssel,OV
,nl,Utrecht,UT
,nl,Zeeland,ZH
,nl,Zuid-Holland,ZL
42 changes: 42 additions & 0 deletions l10n_nl_postcodeapi/i18n/l10n_nl_postcodeapi.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Translation of OpenERP Server.
# This file contains the translation of the following modules:
# * l10n_nl_postcodeapi
#
msgid ""
msgstr ""

#. module: l10n_nl_postcodeapi
#: code:addons/l10n_nl_postcodeapi/model/res_partner.py:46
#, python-format
msgid ""
"Could not verify the connection with the address lookup service (if you want "
"to get rid of this message, please rename or delete the system parameter "
"'l10n_nl_postcodeapi.apikey')."
msgstr ""

#. module: l10n_nl_postcodeapi
#: code:_description:0
#: model:ir.model,name:l10n_nl_postcodeapi.model_res_country_state
#, python-format
msgid "Country state"
msgstr ""

#. module: l10n_nl_postcodeapi
#: code:addons/l10n_nl_postcodeapi/model/res_partner.py:45
#, python-format
msgid "Error"
msgstr ""

#. module: l10n_nl_postcodeapi
#: code:_description:0
#: model:ir.model,name:l10n_nl_postcodeapi.model_res_partner
#, python-format
msgid "Partner"
msgstr ""

#. module: l10n_nl_postcodeapi
#: code:_description:0
#: model:ir.model,name:l10n_nl_postcodeapi.model_ir_config_parameter
#, python-format
msgid "ir.config_parameter"
msgstr ""
50 changes: 50 additions & 0 deletions l10n_nl_postcodeapi/i18n/nl.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Translation of OpenERP Server.
# This file contains the translation of the following modules:
# * l10n_nl_postcodeapi
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 7.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-11-10 11:03+0000\n"
"PO-Revision-Date: 2014-11-10 11:03+0000\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"

#. module: l10n_nl_postcodeapi
#: code:addons/l10n_nl_postcodeapi/model/res_partner.py:46
#, python-format
msgid "Could not verify the connection with the address lookup service (if you want to get rid of this message, please rename or delete the system parameter 'l10n_nl_postcodeapi.apikey')."
msgstr "De verbinding met de postcodeserver kon niet gevalideerd worden (als je deze melding niet meer wilt zien, hernoem of verwijder dan de systeemparameter 'l10n_nl_postcodeapi.apikey')."

#. module: l10n_nl_postcodeapi
#: code:_description:0
#: model:ir.model,name:l10n_nl_postcodeapi.model_res_country_state
#, python-format
msgid "Country state"
msgstr "Staat"

#. module: l10n_nl_postcodeapi
#: code:addons/l10n_nl_postcodeapi/model/res_partner.py:45
#, python-format
msgid "Error"
msgstr "Fout"

#. module: l10n_nl_postcodeapi
#: code:_description:0
#: model:ir.model,name:l10n_nl_postcodeapi.model_res_partner
#, python-format
msgid "Partner"
msgstr "Relatie"

#. module: l10n_nl_postcodeapi
#: code:_description:0
#: model:ir.model,name:l10n_nl_postcodeapi.model_ir_config_parameter
#, python-format
msgid "ir.config_parameter"
msgstr "ir.config_parameter"

3 changes: 3 additions & 0 deletions l10n_nl_postcodeapi/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import res_partner
from . import ir_config_parameter
from . import res_country_state
52 changes: 52 additions & 0 deletions l10n_nl_postcodeapi/models/ir_config_parameter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# This module copyright (C) 2013-2015 Therp BV (<http://therp.nl>).
#
# @autors: Stefan Rijnhart, Ronald Portier
#
# 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/>.
#
##############################################################################

from openerp import models, api


class IrConfigParameter(models.Model):
_inherit = 'ir.config_parameter'

@api.model
def create(self, vals):
"""
Clear the postcode provider cache when the API
key is created
"""
if vals.get('key') == 'l10n_nl_postcodeapi.apikey':
partner_obj = self.env['res.partner']
partner_obj.get_provider_obj.clear_cache(partner_obj)
return super(IrConfigParameter, self).create(vals)

@api.multi
def write(self, vals):
"""
Clear the postcode provider cache when the API
key is modified
"""
key = 'l10n_nl_postcodeapi.apikey'
if (vals.get('key') == key or
self.search([('id', 'in', self.ids), ('key', '=', key)])):
partner_obj = self.env['res.partner']
partner_obj.get_provider_obj.clear_cache(partner_obj)
return super(IrConfigParameter, self).write(vals)
56 changes: 56 additions & 0 deletions l10n_nl_postcodeapi/models/res_country_state.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# This module copyright (C) 2013-2015 Therp BV (<http://therp.nl>).
#
# 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/>.
#
##############################################################################

from openerp import models, api


class ResCountryState(models.Model):
_inherit = 'res.country.state'

@api.multi
def write(self, vals):
"""
Clear the postcode provider cache when the state
table is altered.
"""
self.env['res.partner'].get_province.clear_cache(
self.env['res.partner'])
return super(ResCountryState, self).write(vals)

@api.model
def create(self, vals):
"""
Clear the postcode provider cache when the state
table is altered.
"""
self.env['res.partner'].get_province.clear_cache(
self.env['res.partner'])
return super(ResCountryState, self).create(vals)

@api.multi
def unlink(self):
"""
Clear the postcode provider cache when the state
table is altered.
"""
self.env['res.partner'].get_province.clear_cache(
self.env['res.partner'])
return super(ResCountryState, self).unlink()
Loading

0 comments on commit 90f9547

Please sign in to comment.