Skip to content

Commit

Permalink
[MIG] l10n_nl_partner_name: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
hbrunn committed Jul 22, 2024
1 parent 1a44e8c commit cf879f1
Show file tree
Hide file tree
Showing 12 changed files with 176 additions and 254 deletions.
92 changes: 72 additions & 20 deletions l10n_nl_partner_name/README.rst
Original file line number Diff line number Diff line change
@@ -1,38 +1,90 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
===================
Dutch partner names
===================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:f8cb1b98fe2136d949f732eeda2394f64a6938aff007ab5ad473286ba230240b
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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--netherlands-lightgray.png?logo=github
:target: https://github.com/OCA/l10n-netherlands/tree/16.0/l10n_nl_partner_name
:alt: OCA/l10n-netherlands
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/l10n-netherlands-16-0/l10n-netherlands-16-0-l10n_nl_partner_name
: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-netherlands&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

Use Dutch conventions for partner names:

- have infixes
- have initials
- split first and last name (provided by partner_firstname)

**Table of contents**

.. contents::
:local:

Known issues / Roadmap
======================

Module Dutch Partner Name
=========================
- allow to turn on/off initials and infix separately
- add nickname (roepnaam) field to also turn on and off separately

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

Roadmap
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 to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/l10n-netherlands/issues/new?body=module:%20l10n_nl_partner_name%0Aversion:%2016.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
-------

- allow to turn on/off initials and infix separately
- add nickname (roepnaam) field to also turn on and off separately
* Hunki Enterprises BV
* Therp BV

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

* Holger Brunn <[email protected]>
* Ronald Portier <[email protected]>
* George Daramouskas <[email protected]>

Maintainer
----------
- Holger Brunn <[email protected]>
(https://hunki-enterprises.com)
- Ronald Portier <[email protected]>
- George Daramouskas <[email protected]>

.. image:: http://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: http://odoo-community.org
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.

To contribute to this module, please visit http://odoo-community.org.
This module is part of the `OCA/l10n-netherlands <https://github.com/OCA/l10n-netherlands/tree/16.0/l10n_nl_partner_name>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 1 addition & 1 deletion l10n_nl_partner_name/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from . import model
from . import models
4 changes: 2 additions & 2 deletions l10n_nl_partner_name/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{
"name": "Dutch partner names",
"version": "13.0.1.0.0",
"version": "16.0.1.0.0",
"summary": "Adapt parter names to Dutch conventions (support infix)",
"author": "Therp BV, Odoo Community Association (OCA)",
"author": "Hunki Enterprises BV, Therp BV, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/l10n-netherlands",
"category": "Contact management",
"depends": ["partner_firstname"],
Expand Down
41 changes: 0 additions & 41 deletions l10n_nl_partner_name/model/res_partner.py

This file was deleted.

File renamed without changes.
60 changes: 60 additions & 0 deletions l10n_nl_partner_name/models/res_partner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Copyright 2017-2022 Therp BV <https://therp.nl>.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import api, fields, models


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

_inherit = "res.partner"
_l10n_nl_partner_name_infixes = ("van", "der", "den", "op", "ter", "de", "v/d")

initials = fields.Char()
infix = fields.Char()

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

def _inverse_name(self):
for record in self:
parts = record._get_inverse_name(record.name, record.is_company)
record.update(parts)

@api.model
def _get_computed_name(self, lastname, firstname, initials=None, infix=None):
return " ".join(
filter(
None,
(firstname, ("(%s)" % initials) if initials else None, infix, lastname),
)
)

@api.model
def _get_inverse_name(self, name, is_company=False):
if is_company:
return super()._get_inverse_name(name, is_company=is_company)

def add_token(key, value):
result[key] += (result[key] and " " or "") + value

result = dict.fromkeys(("firstname", "lastname", "initials", "infix"), "")
tokens = (name or "").split()
while len(tokens) > 1:
token = tokens.pop(0)
if all((c.isupper() or c == ".") for c in token):
add_token("initials", token)
elif token[:1] == "(" and token[-1:] == ")":
add_token("initials", token[1:-1])
elif token.lower() in self._l10n_nl_partner_name_infixes:
add_token("infix", token)
elif result["infix"]:
tokens.insert(0, token)
break
else:
add_token("firstname", token)
result["lastname"] = " ".join(tokens)
return result
3 changes: 3 additions & 0 deletions l10n_nl_partner_name/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Holger Brunn \<[email protected]> (https://hunki-enterprises.com)
- Ronald Portier \<[email protected]>
- George Daramouskas \<[email protected]>
4 changes: 4 additions & 0 deletions l10n_nl_partner_name/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Use Dutch conventions for partner names:
- have infixes
- have initials
- split first and last name (provided by partner\_firstname)
2 changes: 2 additions & 0 deletions l10n_nl_partner_name/readme/ROADMAP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- allow to turn on/off initials and infix separately
- add nickname (roepnaam) field to also turn on and off separately
108 changes: 0 additions & 108 deletions l10n_nl_partner_name/scripts/guess_names.py

This file was deleted.

20 changes: 18 additions & 2 deletions l10n_nl_partner_name/tests/test_l10n_nl_partner_name.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,23 @@ def test_l10n_nl_partner_name(self):
partner.firstname = "Willem-Alexander"
partner.lastname = "van Oranje-Nassau"
self.assertEqual(partner.name, "Willem-Alexander van Oranje-Nassau")
partner.write({"name": partner.name})
partner.name = partner.name
self.assertEqual(partner.firstname, "Willem-Alexander")
self.assertEqual(partner.lastname, "van Oranje-Nassau")
self.assertEqual(partner.infix, "van")
self.assertEqual(partner.lastname, "Oranje-Nassau")
self.assertEqual(partner.name, "Willem-Alexander van Oranje-Nassau")
partner.name = "Willem Frederik (W.F.) Hermans"
self.assertEqual(partner.firstname, "Willem Frederik")
self.assertEqual(partner.infix, "")
self.assertEqual(partner.initials, "W.F.")
self.assertEqual(partner.lastname, "Hermans")
self.assertEqual(partner.name, "Willem Frederik (W.F.) Hermans")
partner.name = "Alfred J. Kwack"
self.assertEqual(partner.firstname, "Alfred")
self.assertEqual(partner.infix, "")
self.assertEqual(partner.initials, "J.")
self.assertEqual(partner.lastname, "Kwack")
partner.write({"initials": "A.J."})
self.assertEqual(partner.name, "Alfred (A.J.) Kwack")
partner.name = "Willem-Alexander van Oranje Nassau"
self.assertEqual(partner.lastname, "Oranje Nassau")
Loading

0 comments on commit cf879f1

Please sign in to comment.