Skip to content

Commit

Permalink
Merge 3913cfb into 89a9652
Browse files Browse the repository at this point in the history
  • Loading branch information
hbrunn committed Sep 12, 2015
2 parents 89a9652 + 3913cfb commit 009c17a
Show file tree
Hide file tree
Showing 22 changed files with 998 additions and 3 deletions.
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
Odoo Dutch localization project
===============================

This repository includes all the Odoo v8 modules developed to fit the specific needs of the Netherlands.
For more info check the issues sections and the wikipages in this GitHub project or the main page of the project in the official OCA website (http://odoo-community.org/project/62).
This repository includes all the Odoo modules developed to fit the specific
needs of the Netherlands.
For more info check the issues sections and the wikipages in this GitHub
project or the main page of the project in the OCA website:
http://odoo-community.org/project/62.

--

Deze repository bevat alle modules welke ontwikkeld zijn om Odoo v7 aan te laten sluiten bij de Nederlandse behoeftes. Voor meer informatie kunt u de issues sectie en wiki pagina's in deze GitHub bekijken, of de hoofdpagina bezoeken van dit project op de officiele OCA website (http://odoo-community.org/project/62).
Deze repository bevat alle modules welke ontwikkeld zijn om Odoo aan te laten
sluiten bij de Nederlandse behoeftes.
Voor meer informatie kunt u de issues sectie en wiki pagina's in deze GitHub
bekijken, of de hoofdpagina bezoeken van dit project op de OCA website:
http://odoo-community.org/project/62.
31 changes: 31 additions & 0 deletions l10n_nl_partner_name/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:alt: License: AGPL-3

Module Dutch Partner Name
=========================

Use Dutch conventions for partner names:
- have infixes
- have initials
- split first and last name (provided by partner_firstname)

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

* Holger Brunn <hbrunn@therp.nl>
* Ronald Portier <ronald@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.

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.
21 changes: 21 additions & 0 deletions l10n_nl_partner_name/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# This module copyright (C) 2013 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 . import model
40 changes: 40 additions & 0 deletions l10n_nl_partner_name/__openerp__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# -*- 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': 'Dutch partner names',
'version': '1.0',
'author': 'Therp BV, Odoo Community Association (OCA)',
'category': 'Contact management',
'depends': [
'partner_firstname',
],
'data': [
'view/res_partner.xml',
],
'js': [],
'css': [],
'qweb': [],
'auto_install': False,
'installable': True,
'external_dependencies': {
'python': ['mako'],
},
}
39 changes: 39 additions & 0 deletions l10n_nl_partner_name/i18n/l10n_nl_partner_name.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Translation of OpenERP Server.
# This file contains the translation of the following modules:
# * l10n_nl_partner_name
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 7.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-01-02 12:30+0000\n"
"PO-Revision-Date: 2015-01-02 12:30+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_partner_name
#: field:res.partner,infix:0
msgid "Infix"
msgstr ""

#. module: l10n_nl_partner_name
#: field:res.partner,initials:0
msgid "Initials"
msgstr ""

#. module: l10n_nl_partner_name
#: field:res.partner,parent_name:0
msgid "Parent name"
msgstr ""

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

31 changes: 31 additions & 0 deletions l10n_nl_partner_name/i18n/nl.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Translation of OpenERP Server.
# This file contains the translation of the following modules:
# * l10n_nl_partner_name
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 7.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-10-02 14:42+0000\n"
"PO-Revision-Date: 2013-10-02 14:42+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_partner_name
#: model:ir.model,name:l10n_nl_partner_name.model_res_partner
msgid "Partner"
msgstr "Relatie"

#. module: l10n_nl_partner_name
#: field:res.partner,infix:0
msgid "Infix"
msgstr "Tussenvoegsel"

#. module: l10n_nl_partner_name
#: field:res.partner,initials:0
msgid "Initials"
msgstr "Voorletters"
24 changes: 24 additions & 0 deletions l10n_nl_partner_name/model/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
"""Extentions for models."""
##############################################################################
#
# OpenERP, Open Source Management Solution
# This module copyright (C) 2013 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 . import res_partner

# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
61 changes: 61 additions & 0 deletions l10n_nl_partner_name/model/res_partner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# -*- coding: utf-8 -*-
"""Extend res.partner with extra fields for Dutch names."""
##############################################################################
#
# 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 mako.template import Template
from openerp import models, fields, api


class ResPartner(models.Model):
"""Extend res.partner with extra fields for Dutch names."""
_inherit = 'res.partner'

initials = fields.Char(size=16)
infix = fields.Char(size=32)

@api.one
@api.depends("firstname", "lastname", "initials", "infix")
def _compute_name(self):
self.name = self._get_computed_name(
self.lastname, self.firstname, self.initials, self.infix)

@api.one
@api.onchange("firstname", "lastname", "initials", "infix")
def _onchange_subnames(self):
return super(ResPartner, self)._onchange_subnames()

@api.model
def _get_computed_name(self, lastname, firstname, initials=None,
infix=None):
name_template = Template(
self.env.context.get(
'name_format',
"${firstname or initials or ''}"
"${(firstname or initials) and ' ' or ''}"
"${infix or ''}${infix and ' ' or ''}${lastname}"))
name = name_template.render(**{
'firstname': firstname,
'lastname': lastname,
'initials': initials,
'infix': infix,
})
return name if name else ''

# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
78 changes: 78 additions & 0 deletions l10n_nl_partner_name/scripts/guess_names.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#!/usr/bin/python

import argparse
import xmlrpclib
import re
parser = argparse.ArgumentParser()
parser.add_argument('openerp_host')
parser.add_argument('openerp_db')
parser.add_argument('openerp_user')
parser.add_argument('openerp_passwd')
parser.add_argument('additional_search', nargs='?')
args = parser.parse_args()

openerp_socket = xmlrpclib.ServerProxy(
'http://%s/xmlrpc/common' % args.openerp_host)
openerp_uid = openerp_socket.login(
args.openerp_db, args.openerp_user, args.openerp_passwd)
openerp_socket = xmlrpclib.ServerProxy(
'http://%s/xmlrpc/object' % args.openerp_host, allow_none=True)


def openerp_execute(model, method, *pargs, **kwargs):
return openerp_socket.execute(
args.openerp_db, openerp_uid,
args.openerp_passwd, model, method, *pargs, **kwargs)

infixes = ['van', 'der', 'ter', 'de', 'v/d']
initial = re.compile(r'^([A-Z]{1,3}\.{0,1}){1,4}$')

limit = 100000
offset = 0


def add_token(values, key, token, delimiter=' '):
values[key] = (values[key] + ' ' if values[key] else '') + token

while True:
ids = openerp_execute(
'res.partner', 'search',
[
('lastname', '!=', False),
('lastname', '!=', ''),
('firstname', '=', False),
('initials', '=', False),
('infix', '=', False),
('is_company', '=', False),
] +
eval(args.additional_search or '[]'),
offset,
limit)
if not ids:
break

for partner in openerp_execute(
'res.partner', 'read', ids,
['lastname', 'firstname', 'initials', 'infix']):
print partner['lastname']

have_infix = False
tokens = partner['lastname'].split()
while len(tokens) > 1:
token = tokens.pop(0)
if initial.match(token):
add_token(partner, 'initials', token)
elif any(map(lambda infix: re.match(infix, token, re.I), infixes)):
add_token(partner, 'infix', token.lower())
have_infix = True
else:
if have_infix:
tokens.insert(0, token)
break
add_token(partner, 'firstname', token)
partner['lastname'] = ' '.join(tokens)

print partner
openerp_execute('res.partner', 'write', partner['id'], partner)

offset += limit
Binary file added l10n_nl_partner_name/static/src/img/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions l10n_nl_partner_name/view/res_partner.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<openerp>
<data>
<record id="view_partner_simple_form_firstname" model="ir.ui.view">
<field name="name">res.partner.simplified.form.firstname</field>
<field name="model">res.partner</field>
<field
name="inherit_id"
ref="partner_firstname.view_partner_simple_form_firstname"
/>
<field name="arch" type="xml">
<data>
<field name="lastname" position="after">
<field name="initials" />
<field name="infix" />
</field>
</data>
</field>
</record>

<record id="view_partner_form_firstname" model="ir.ui.view">
<field name="name">res.partner.form.firstname</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="partner_firstname.view_partner_form_firstname"/>
<field name="arch" type="xml">
<data>
<field name="lastname" position="after">
<field name="initials" />
<field name="infix" />
</field>
<xpath
expr="//form[@string='Contact']/sheet//group/field[@name='lastname']"
position="after"
>
<field name="initials"/>
<field name="infix"/>
</xpath>
</data>
</field>
</record>

</data>
</openerp>
Loading

0 comments on commit 009c17a

Please sign in to comment.