diff --git a/README.md b/README.md index ab3fa6c96..eda0091c2 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/l10n_nl_partner_name/README.rst b/l10n_nl_partner_name/README.rst new file mode 100644 index 000000000..63e1dd68c --- /dev/null +++ b/l10n_nl_partner_name/README.rst @@ -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 +* Ronald Portier + +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. diff --git a/l10n_nl_partner_name/__init__.py b/l10n_nl_partner_name/__init__.py new file mode 100644 index 000000000..9da2ac3b6 --- /dev/null +++ b/l10n_nl_partner_name/__init__.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# This module copyright (C) 2013 Therp BV (). +# +# 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 . +# +############################################################################## +from . import model diff --git a/l10n_nl_partner_name/__openerp__.py b/l10n_nl_partner_name/__openerp__.py new file mode 100644 index 000000000..46ecc83fc --- /dev/null +++ b/l10n_nl_partner_name/__openerp__.py @@ -0,0 +1,40 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# This module copyright (C) 2013-2015 Therp BV . +# +# 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 . +# +############################################################################## +{ + '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'], + }, +} diff --git a/l10n_nl_partner_name/i18n/l10n_nl_partner_name.pot b/l10n_nl_partner_name/i18n/l10n_nl_partner_name.pot new file mode 100644 index 000000000..582a5db05 --- /dev/null +++ b/l10n_nl_partner_name/i18n/l10n_nl_partner_name.pot @@ -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 "" + diff --git a/l10n_nl_partner_name/i18n/nl.po b/l10n_nl_partner_name/i18n/nl.po new file mode 100644 index 000000000..3b6dd6488 --- /dev/null +++ b/l10n_nl_partner_name/i18n/nl.po @@ -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" diff --git a/l10n_nl_partner_name/model/__init__.py b/l10n_nl_partner_name/model/__init__.py new file mode 100644 index 000000000..d6656d529 --- /dev/null +++ b/l10n_nl_partner_name/model/__init__.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +"""Extentions for models.""" +############################################################################## +# +# OpenERP, Open Source Management Solution +# This module copyright (C) 2013 Therp BV (). +# +# 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 . +# +############################################################################## +from . import res_partner + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/l10n_nl_partner_name/model/res_partner.py b/l10n_nl_partner_name/model/res_partner.py new file mode 100644 index 000000000..b680832cf --- /dev/null +++ b/l10n_nl_partner_name/model/res_partner.py @@ -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 . +# +# 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 . +# +############################################################################## +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: diff --git a/l10n_nl_partner_name/scripts/guess_names.py b/l10n_nl_partner_name/scripts/guess_names.py new file mode 100644 index 000000000..d0f0ce8fa --- /dev/null +++ b/l10n_nl_partner_name/scripts/guess_names.py @@ -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 diff --git a/l10n_nl_partner_name/static/src/img/icon.png b/l10n_nl_partner_name/static/src/img/icon.png new file mode 100644 index 000000000..48485f76e Binary files /dev/null and b/l10n_nl_partner_name/static/src/img/icon.png differ diff --git a/l10n_nl_partner_name/view/res_partner.xml b/l10n_nl_partner_name/view/res_partner.xml new file mode 100644 index 000000000..537f51554 --- /dev/null +++ b/l10n_nl_partner_name/view/res_partner.xml @@ -0,0 +1,42 @@ + + + + res.partner.simplified.form.firstname + res.partner + + + + + + + + + + + + + res.partner.form.firstname + res.partner + + + + + + + + + + + + + + + + + diff --git a/l10n_nl_partner_salutation/README.rst b/l10n_nl_partner_salutation/README.rst new file mode 100644 index 000000000..ef6c1f8a4 --- /dev/null +++ b/l10n_nl_partner_salutation/README.rst @@ -0,0 +1,43 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :alt: License: AGPL-3 + +Module Dutch Partner Name +========================= + +This module splits off a gender field from the partner title. New fields +are added to the title model to express the salutation of partners, in +combination with the gender field. Based on partner_name_dutch, you can +then refer to function fields generating full salutations to use at the +start of a letter, or short versions to be used in addresses. + +The interface allows to change generated salutations manually, after which +these will not be updated anymore after changes in the partner name or title. +While the manually entered salutations are stored in separate fields, the +function fields refer to their values when manual changes are active so you +should always use the function fields in your document templates. + +While organizations have no gender (the field is hidden there), you can have +a feminine salutation by creating a partner title with an implicit gender, +such as 'Ladies club'. + +Contributors +------------ + +* Holger Brunn +* Ronald Portier +* Stefan Rijnhart + +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. diff --git a/l10n_nl_partner_salutation/__init__.py b/l10n_nl_partner_salutation/__init__.py new file mode 100644 index 000000000..9186ee3ad --- /dev/null +++ b/l10n_nl_partner_salutation/__init__.py @@ -0,0 +1 @@ +from . import model diff --git a/l10n_nl_partner_salutation/__openerp__.py b/l10n_nl_partner_salutation/__openerp__.py new file mode 100644 index 000000000..4df67fcc8 --- /dev/null +++ b/l10n_nl_partner_salutation/__openerp__.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Odoo, a suite of open source business applications +# This module copyright (C) 2014-2015 Therp BV . +# +# 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 . +# +############################################################################## +{ + 'name': 'Full salutation for partners, Dutch style', + 'version': '1.0', + 'author': 'Therp BV, Odoo Community Association (OCA)', + 'category': 'Contact management', + 'depends': [ + 'l10n_nl_partner_name', + ], + 'data': [ + 'data/res_partner_title.xml', + 'view/res_partner_title.xml', + 'view/res_partner.xml', + ], +} diff --git a/l10n_nl_partner_salutation/data/res_partner_title.xml b/l10n_nl_partner_salutation/data/res_partner_title.xml new file mode 100644 index 000000000..a7325f88f --- /dev/null +++ b/l10n_nl_partner_salutation/data/res_partner_title.xml @@ -0,0 +1,23 @@ + + + + + Prof. + + + Dr. + + + Mister + + + Miss + + + Madam + + + Sir + + + diff --git a/l10n_nl_partner_salutation/i18n/l10n_nl_partner_salutation.pot b/l10n_nl_partner_salutation/i18n/l10n_nl_partner_salutation.pot new file mode 100644 index 000000000..d6aaf39ce --- /dev/null +++ b/l10n_nl_partner_salutation/i18n/l10n_nl_partner_salutation.pot @@ -0,0 +1,102 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_nl_partner_salutation +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-04-17 10:40+0000\n" +"PO-Revision-Date: 2015-04-17 10:40+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_salutation +#: view:res.partner:l10n_nl_partner_salutation.view_partner_form +msgid "Contacts" +msgstr "" + +#. module: l10n_nl_partner_salutation +#: field:res.partner,use_manual_salutations:0 +msgid "Enter salutations manually" +msgstr "" + +#. module: l10n_nl_partner_salutation +#: selection:res.partner,gender:0 +msgid "Female" +msgstr "" + +#. module: l10n_nl_partner_salutation +#: field:res.partner,gender:0 +msgid "Gender" +msgstr "" + +#. module: l10n_nl_partner_salutation +#: selection:res.partner,gender:0 +msgid "Male" +msgstr "" + +#. module: l10n_nl_partner_salutation +#: field:res.partner,salutation_address_manual:0 +msgid "Manual salutation (address)" +msgstr "" + +#. module: l10n_nl_partner_salutation +#: field:res.partner,salutation_manual:0 +msgid "Manual salutation (letter)" +msgstr "" + +#. module: l10n_nl_partner_salutation +#: model:ir.model,name:l10n_nl_partner_salutation.model_res_partner +msgid "Partner" +msgstr "" + +#. module: l10n_nl_partner_salutation +#: field:res.partner.title,postnominal:0 +msgid "Postnominal" +msgstr "" + +#. module: l10n_nl_partner_salutation +#: view:res.partner:l10n_nl_partner_salutation.view_partner_form +msgid "Salutation" +msgstr "" + +#. module: l10n_nl_partner_salutation +#: view:res.partner:l10n_nl_partner_salutation.view_partner_form +msgid "Salutation (address)" +msgstr "" + +#. module: l10n_nl_partner_salutation +#: view:res.partner:l10n_nl_partner_salutation.view_partner_form +msgid "Salutation (letter)" +msgstr "" + +#. module: l10n_nl_partner_salutation +#: field:res.partner.title,salutation_female:0 +msgid "Salutation female" +msgstr "" + +#. module: l10n_nl_partner_salutation +#: field:res.partner.title,salutation_male:0 +msgid "Salutation male" +msgstr "" + +#. module: l10n_nl_partner_salutation +#: field:res.partner.title,shortcut_female:0 +msgid "Shortcut female" +msgstr "" + +#. module: l10n_nl_partner_salutation +#: field:res.partner.title,shortcut_male:0 +msgid "Shortcut male" +msgstr "" + +#. module: l10n_nl_partner_salutation +#: selection:res.partner,gender:0 +msgid "Unknown" +msgstr "" + diff --git a/l10n_nl_partner_salutation/i18n/nl.po b/l10n_nl_partner_salutation/i18n/nl.po new file mode 100644 index 000000000..2d2a78846 --- /dev/null +++ b/l10n_nl_partner_salutation/i18n/nl.po @@ -0,0 +1,148 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * l10n_nl_partner_salutation +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-09-02 14:52+0000\n" +"PO-Revision-Date: 2014-09-02 14:52+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_salutation +#: view:res.partner:0 +msgid "Contacts" +msgstr "Contactpersonen" + +#. module: l10n_nl_partner_salutation +#: field:res.partner.title,salutation:0 +msgid "Salutation" +msgstr "Aanhef" + +#. module: l10n_nl_partner_salutation +#: field:res.partner,use_manual_salutations:0 +msgid "Enter salutations manually" +msgstr "Aanhef handmatig invoeren" + +#. module: l10n_nl_partner_salutation +#: selection:res.partner,gender:0 +msgid "Female" +msgstr "Vrouw" + +#. module: l10n_nl_partner_salutation +#: field:res.partner,gender:0 +msgid "Gender" +msgstr "Geslacht" + +#. module: l10n_nl_partner_salutation +#: selection:res.partner,gender:0 +msgid "Male" +msgstr "Man" + +#. module: l10n_nl_partner_salutation +#: field:res.partner,salutation_address_manual:0 +msgid "Manual salutation (address)" +msgstr "Aanhef handmatig (op adres)" + +#. module: l10n_nl_partner_salutation +#: field:res.partner,salutation_manual:0 +msgid "Manual salutation (letter)" +msgstr "Manual salutation (letter)" + +#. module: l10n_nl_partner_salutation +#: code:_description:0 +#: model:ir.model,name:l10n_nl_partner_salutation.model_res_partner +#, python-format +msgid "Partner" +msgstr "Relatie" + +#. module: l10n_nl_partner_salutation +#: field:res.partner.title,postnominal:0 +msgid "Postnominal" +msgstr "Achtervoegsel" + +#. module: l10n_nl_partner_salutation +#: view:res.partner:0 +msgid "Salutation" +msgstr "Aanhef" + +#. module: l10n_nl_partner_salutation +#: view:res.partner:0 +#: field:res.partner,salutation_address:0 +msgid "Salutation (address)" +msgstr "Aanhef (op adres)" + +#. module: l10n_nl_partner_salutation +#: view:res.partner:0 +#: field:res.partner,salutation:0 +msgid "Salutation (letter)" +msgstr "Aanhef (brief)" + +#. module: l10n_nl_partner_salutation +#: field:res.partner.title,salutation_female:0 +msgid "Salutation female" +msgstr "Aanhef (v)" + +#. module: l10n_nl_partner_salutation +#: field:res.partner.title,salutation_male:0 +msgid "Salutation male" +msgstr "Aanhef (m)" + +#. module: l10n_nl_partner_salutation +#: field:res.partner.title,shortcut_female:0 +msgid "Shortcut female" +msgstr "Afkorting (v)" + +#. module: l10n_nl_partner_salutation +#: field:res.partner.title,shortcut_male:0 +msgid "Shortcut male" +msgstr "Afkorting (m)" + +#. module: l10n_nl_partner_salutation +#: selection:res.partner,gender:0 +msgid "Unknown" +msgstr "Onbekend" + +#. module: l10n_nl_partner_salutation +#: code:_description:0 +#: model:ir.model,name:l10n_nl_partner_salutation.model_res_partner_title +#, python-format +msgid "res.partner.title" +msgstr "res.partner.title" + +#. module: l10n_nl_partner_salutation +#: model:res.partner.title,salutation:base.res_partner_title_prof +msgid "Prof." +msgstr "prof." + +#. module: l10n_nl_partner_salutation +#: model:res.partner.title,salutation:base.res_partner_title_doctor +msgid "Dr." +msgstr "dr." + +#. module: l10n_nl_partner_salutation +#: model:res.partner.title,salutation:base.res_partner_title_mister +msgid "Mister" +msgstr "heer" + +#. module: l10n_nl_partner_salutation +#: model:res.partner.title,salutation:base.res_partner_title_miss +msgid "Miss" +msgstr "mejuffrouw" + +#. module: l10n_nl_partner_salutation +#: model:res.partner.title,salutation:base.res_partner_title_madam +msgid "Madam" +msgstr "mevrouw" + +#. module: l10n_nl_partner_salutation +#: model:res.partner.title,salutation:base.res_partner_title_sir +msgid "Sir" +msgstr "heer" + diff --git a/l10n_nl_partner_salutation/model/__init__.py b/l10n_nl_partner_salutation/model/__init__.py new file mode 100644 index 000000000..a4f50d57f --- /dev/null +++ b/l10n_nl_partner_salutation/model/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +"""Extentions for models.""" +############################################################################## +# +# OpenERP, Open Source Management Solution +# This module copyright (C) 2015 Therp BV . +# +# 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 . +# +############################################################################## +from . import res_partner_title +from . import res_partner diff --git a/l10n_nl_partner_salutation/model/res_partner.py b/l10n_nl_partner_salutation/model/res_partner.py new file mode 100644 index 000000000..5543f5f09 --- /dev/null +++ b/l10n_nl_partner_salutation/model/res_partner.py @@ -0,0 +1,121 @@ +# -*- coding: utf-8 -*- +"""Extend res.partner model.""" +############################################################################## +# +# OpenERP, Open Source Management Solution +# This module copyright (C) 2014-2015 Therp BV . +# +# 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 . +# +############################################################################## +from openerp import api, models, fields + +GENDERS = [('male', 'Male'), ('female', 'Female'), ('unknown', 'Unknown')] + + +class ResPartner(models.Model): + """Extend res.partner model.""" + _inherit = 'res.partner' + + @api.onchange('use_manual_salutations') + def on_change_use_manual_salutations(self): + """Handle onchange event.""" + if self.use_manual_salutations: + # When changing to manual salutation, initially + # use the computed fields for default. + self.salutation_manual = self.salutation + self.salutation_address_manual = self.salutation_address + + def get_salutation_name_format(self): + """Return the desired name format for use in the salutation.""" + return ( + "${firstname or initials or ''}" + "${' ' if (firstname or initials) else ''}" + "${infix or ''}" + "${' ' if infix else ''}" + "${lastname or ''}" + ) + + @api.depends( + 'gender', + 'title', + 'use_manual_salutations', + 'salutation_manual', + 'salutation_address_manual' + ) + def _get_salutation(self): + """Return the salutation fields.""" + + def get_prefix(field, partner): + """ + Get genderized values for the given field, with a fallback + on the field if the partner has no gender or the genderized + field itself has no value. + """ + val = '' + if partner.gender in ('male', 'female'): + val = partner.title[field + '_' + partner.gender] + if not val: + val = partner.title[field] or default_prefix[ + field][partner.gender or 'unknown'] + return val + ' ' + + default_prefix = { + 'shortcut': { + 'male': 'De heer', + 'female': 'Mevrouw', + 'unknown': 'De heer of mevrouw', + }, + 'salutation': { + 'male': 'Geachte heer', + 'female': 'Geachte mevrouw', + 'unknown': 'Geachte heer of mevrouw', + } + } + name_format = self.get_salutation_name_format() + for rec in self: + rec.salutation = False + rec.salutation_address = False + if rec.use_manual_salutations: + rec.salutation = rec.salutation_manual or False + rec.salutation_address = rec.salutation_address_manual or False + # Use API from partner_firstname + name = self.with_context(name_format=name_format)\ + ._get_computed_name( + rec.lastname, rec.firstname, initials=rec.initials, + infix=rec.infix) + # Apply prefix/or and suffix + if not rec.salutation: + rec.salutation = get_prefix('salutation', rec) + name + if rec.title.postnominal: + rec.salutation += ' ' + rec.title.postnominal + if not rec.salutation_address: + rec.salutation_address = get_prefix('shortcut', rec) + name + if rec.title.postnominal: + rec.salutation_address += ' ' + rec.title.postnominal + + gender = fields.Selection(GENDERS, required=True, default='unknown') + salutation = fields.Char( + compute='_get_salutation', + string='Salutation (letter)' + ) + salutation_address = fields.Char( + compute='_get_salutation', + string='Salutation (address)' + ) + use_manual_salutations = fields.Boolean('Enter salutations manually') + salutation_manual = fields.Char('Manual salutation (letter)') + salutation_address_manual = fields.Char('Manual salutation (address)') + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/l10n_nl_partner_salutation/model/res_partner_title.py b/l10n_nl_partner_salutation/model/res_partner_title.py new file mode 100644 index 000000000..6423b6f58 --- /dev/null +++ b/l10n_nl_partner_salutation/model/res_partner_title.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- +"""Extend res.partner.title model.""" +############################################################################## +# +# OpenERP, Open Source Management Solution +# This module copyright (C) 2014-2015 Therp BV . +# +# 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 . +# +############################################################################## +from openerp import models, fields + + +class ResPartnerTitle(models.Model): + """Extend res.partner.title model.""" + _inherit = 'res.partner.title' + + salutation = fields.Char(size=64, translate=True) + salutation_male = fields.Char(string='Salutation male') + salutation_female = fields.Char(string='Salutation female') + shortcut_male = fields.Char(string='Shortcut male') + shortcut_female = fields.Char(string='Shortcut female') + postnominal = fields.Char(string='Postnominal') + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/l10n_nl_partner_salutation/view/res_partner.xml b/l10n_nl_partner_salutation/view/res_partner.xml new file mode 100644 index 000000000..98748c873 --- /dev/null +++ b/l10n_nl_partner_salutation/view/res_partner.xml @@ -0,0 +1,48 @@ + + + + + + + res.partner + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/l10n_nl_partner_salutation/view/res_partner_title.xml b/l10n_nl_partner_salutation/view/res_partner_title.xml new file mode 100644 index 000000000..d9edce573 --- /dev/null +++ b/l10n_nl_partner_salutation/view/res_partner_title.xml @@ -0,0 +1,42 @@ + + + + + res.partner.title + + + + + + + + + + + + + res.partner.title + + + + + + + + + + + + + + + + + + + + + + + +