diff --git a/l10n_nl_partner_name/README.rst b/l10n_nl_partner_name/README.rst
index 424ab9340..312313831 100644
--- a/l10n_nl_partner_name/README.rst
+++ b/l10n_nl_partner_name/README.rst
@@ -39,6 +39,23 @@ Use Dutch conventions for partner names:
.. contents::
:local:
+Configuration
+=============
+
+The module relies on a list of known infixes to get the parsing right:
+
+van, der, den, op, ter, de, v/d, d', 't, te
+
+Also any combination, so *op den*, *van der* etc will also be
+recognized.
+
+If you need a different set of infixes, set system parameter
+``l10n_nl_partner_name_infixes`` to a comma separated list like
+
+infix1,infix2,etc
+
+Note this replaces the above list.
+
Known issues / Roadmap
======================
diff --git a/l10n_nl_partner_name/models/res_partner.py b/l10n_nl_partner_name/models/res_partner.py
index 2c9efb180..8c4e012a2 100644
--- a/l10n_nl_partner_name/models/res_partner.py
+++ b/l10n_nl_partner_name/models/res_partner.py
@@ -7,7 +7,6 @@ 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()
@@ -41,6 +40,7 @@ def _get_inverse_name(self, name, is_company=False):
def add_token(key, value):
result[key] += (result[key] and " " or "") + value
+ infixes = self._l10n_nl_partner_name_infixes()
result = dict.fromkeys(("firstname", "lastname", "initials", "infix"), "")
tokens = (name or "").split()
while len(tokens) > 1:
@@ -49,7 +49,12 @@ def add_token(key, value):
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:
+ elif (
+ len(tokens) and " ".join([token.lower(), tokens[0].lower()]) in infixes
+ ):
+ add_token("infix", " ".join([token.lower(), tokens[0].lower()]))
+ tokens.pop(0)
+ elif token.lower() in infixes:
add_token("infix", token)
elif result["infix"]:
tokens.insert(0, token)
@@ -58,3 +63,15 @@ def add_token(key, value):
add_token("firstname", token)
result["lastname"] = " ".join(tokens)
return result
+
+ def _l10n_nl_partner_name_infixes(self):
+ return tuple(
+ map(
+ str.strip,
+ self.env["ir.config_parameter"]
+ .get_param(
+ "l10n_nl_partner_name_infixes", "van,der,den,op,ter,de,v/d,d','t,te"
+ )
+ .split(","),
+ )
+ )
diff --git a/l10n_nl_partner_name/readme/CONFIGURE.md b/l10n_nl_partner_name/readme/CONFIGURE.md
new file mode 100644
index 000000000..fcd82c72c
--- /dev/null
+++ b/l10n_nl_partner_name/readme/CONFIGURE.md
@@ -0,0 +1,11 @@
+The module relies on a list of known infixes to get the parsing right:
+
+van, der, den, op, ter, de, v/d, d', 't, te
+
+Also any combination, so *op den*, *van der* etc will also be recognized.
+
+If you need a different set of infixes, set system parameter `l10n_nl_partner_name_infixes` to a comma separated list like
+
+infix1,infix2,etc
+
+Note this replaces the above list.
diff --git a/l10n_nl_partner_name/static/description/index.html b/l10n_nl_partner_name/static/description/index.html
new file mode 100644
index 000000000..b1e27b9f4
--- /dev/null
+++ b/l10n_nl_partner_name/static/description/index.html
@@ -0,0 +1,449 @@
+
+
+
+
+
+Dutch partner names
+
+
+
+
+
Dutch partner names
+
+
+
+
Use Dutch conventions for partner names:
+
+- have infixes
+- have initials
+- split first and last name (provided by partner_firstname)
+
+
Table of contents
+
+
+
+
The module relies on a list of known infixes to get the parsing right:
+
van, der, den, op, ter, de, v/d, d’, ‘t, te
+
Also any combination, so op den, van der etc will also be
+recognized.
+
If you need a different set of infixes, set system parameter
+l10n_nl_partner_name_infixes to a comma separated list like
+
infix1,infix2,etc
+
Note this replaces the above list.
+
+
+
+
+- allow to turn on/off initials and infix separately
+- add nickname (roepnaam) field to also turn on and off separately
+
+
+
+
+
Bugs are tracked on GitHub 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.
+
Do not contact contributors directly about support or help with technical issues.
+
+
+
+
+
+
+- Hunki Enterprises BV
+- Therp BV
+
+
+
+
+
+
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.
+
This module is part of the OCA/l10n-netherlands project on GitHub.
+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
+
+
+
+
+
diff --git a/l10n_nl_partner_name/tests/test_l10n_nl_partner_name.py b/l10n_nl_partner_name/tests/test_l10n_nl_partner_name.py
index 1430afffa..d7bd50295 100644
--- a/l10n_nl_partner_name/tests/test_l10n_nl_partner_name.py
+++ b/l10n_nl_partner_name/tests/test_l10n_nl_partner_name.py
@@ -31,3 +31,12 @@ def test_l10n_nl_partner_name(self):
self.assertEqual(partner.name, "Alfred (A.J.) Kwack")
partner.name = "Willem-Alexander van Oranje Nassau"
self.assertEqual(partner.lastname, "Oranje Nassau")
+ self.env["ir.config_parameter"].set_param(
+ "l10n_nl_partner_name_infixes", "von der, van"
+ )
+ partner.name = "Ursula von der Leyen"
+ self.assertEqual(partner.lastname, "Leyen")
+ self.assertEqual(partner.firstname, "Ursula")
+ self.assertEqual(partner.infix, "von der")
+ partner.name = "Willem-Alexander van Oranje Nassau"
+ self.assertEqual(partner.lastname, "Oranje Nassau")