From 6434271d58538d81dcbf0b01e947438d2992556b Mon Sep 17 00:00:00 2001
From: Nikul-OSI
Date: Tue, 18 Apr 2023 18:45:21 +0530
Subject: [PATCH 01/14] [ADD] partner_middlename: Added in v16
---
partner_middlename/README.rst | 119 ++++++++++++++++++
partner_middlename/__init__.py | 4 +
partner_middlename/__manifest__.py | 15 +++
partner_middlename/models/__init__.py | 5 +
.../models/res_config_settings.py | 34 +++++
partner_middlename/models/res_partner.py | 119 ++++++++++++++++++
partner_middlename/readme/CONFIGURE.rst | 1 +
partner_middlename/readme/CONTRIBUTORS.rst | 3 +
partner_middlename/readme/DESCRIPTION.rst | 1 +
partner_middlename/readme/USAGE.rst | 5 +
.../static/description/icon.png | Bin 0 -> 9455 bytes
partner_middlename/views/res_partner.xml | 80 ++++++++++++
partner_middlename/views/res_user.xml | 26 ++++
13 files changed, 412 insertions(+)
create mode 100644 partner_middlename/README.rst
create mode 100644 partner_middlename/__init__.py
create mode 100644 partner_middlename/__manifest__.py
create mode 100644 partner_middlename/models/__init__.py
create mode 100644 partner_middlename/models/res_config_settings.py
create mode 100644 partner_middlename/models/res_partner.py
create mode 100644 partner_middlename/readme/CONFIGURE.rst
create mode 100644 partner_middlename/readme/CONTRIBUTORS.rst
create mode 100644 partner_middlename/readme/DESCRIPTION.rst
create mode 100644 partner_middlename/readme/USAGE.rst
create mode 100644 partner_middlename/static/description/icon.png
create mode 100644 partner_middlename/views/res_partner.xml
create mode 100644 partner_middlename/views/res_user.xml
diff --git a/partner_middlename/README.rst b/partner_middlename/README.rst
new file mode 100644
index 00000000000..a1f27282983
--- /dev/null
+++ b/partner_middlename/README.rst
@@ -0,0 +1,119 @@
+========================
+Partner second last name
+========================
+
+.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ !! This file is generated by oca-gen-addon-readme !!
+ !! changes will be overwritten. !!
+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+.. |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%2Fpartner--contact-lightgray.png?logo=github
+ :target: https://github.com/OCA/partner-contact/tree/16.0/partner_second_lastname
+ :alt: OCA/partner-contact
+.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
+ :target: https://translation.odoo-community.org/projects/partner-contact-16-0/partner-contact-16-0-partner_second_lastname
+ :alt: Translate me on Weblate
+.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
+ :target: https://runbot.odoo-community.org/runbot/134/16.0
+ :alt: Try me on Runbot
+
+|badge1| |badge2| |badge3| |badge4| |badge5|
+
+This module was written to extend the functionality of ``partner_firstname`` to
+support having a second lastname for contact partners.
+
+In some countries, it's important to have a second last name for contacts.
+
+Contact partners will need to fill at least one of the name fields
+(*First name*, *First last name* or *Second last name*).
+
+**Table of contents**
+
+.. contents::
+ :local:
+
+Configuration
+=============
+
+You can configure some common name patterns for the inverse function
+in Settings > Configuration > General settings:
+
+* Lastname SecondLastname Firstname: For example 'Anderson Lavarge Robert'
+* Lastname SecondLastname, Firstname: For example 'Anderson Lavarge, Robert'
+* Firstname Lastname SecondLastname: For example 'Robert Anderson Lavarge'
+
+After applying the changes, you can recalculate all partners name clicking
+"Recalculate names" button. Note: This process could take so much time depending
+how many partners there are in database.
+
+You can use *_get_inverse_name* method to get firstname, lastname and
+second lastname from a simple string and also *_get_computed_name* to get a
+name form the firstname, lastname and second lastname.
+These methods can be overridden to change the format specified above.
+
+Usage
+=====
+
+To use this module, you need to:
+
+* Edit any partner's form.
+* Make sure the partner is not a company.
+* Enter firstname and lastnames.
+
+If you directly enter the full name instead of entering the other fields
+separately (maybe from other form), this module will try to guess the best
+match for your input and split it between firstname, lastname and second
+lastname using an inverse function.
+
+If you can, always enter it manually please. Automatic guessing could fail for
+you easily in some corner cases.
+
+Bug Tracker
+===========
+
+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 smashing it by providing a detailed and welcomed
+`feedback `_.
+
+Do not contact contributors directly about support or help with technical issues.
+
+Credits
+=======
+
+Authors
+~~~~~~~
+
+* Tecnativa
+
+Contributors
+~~~~~~~~~~~~
+
+* Jairo Llopis .
+* Antonio Espinosa.
+* Pedro M. Baeza .
+* Nikul Chaudhary
+* Manuel Regidor
+
+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.
+
+This module is part of the `OCA/partner-contact `_ project on GitHub.
+
+You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
diff --git a/partner_middlename/__init__.py b/partner_middlename/__init__.py
new file mode 100644
index 00000000000..4c4be2fcbcb
--- /dev/null
+++ b/partner_middlename/__init__.py
@@ -0,0 +1,4 @@
+# Copyright (C) 2023 Open Source Integrators
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
+
+from . import models
diff --git a/partner_middlename/__manifest__.py b/partner_middlename/__manifest__.py
new file mode 100644
index 00000000000..e9daf365ba1
--- /dev/null
+++ b/partner_middlename/__manifest__.py
@@ -0,0 +1,15 @@
+# Copyright (C) 2023 Open Source Integrators
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
+
+{
+ "name": "Partner Middle Name",
+ "summary": "Have split Middle",
+ "version": "16.0.1.0.0",
+ "license": "AGPL-3",
+ "website": "https://github.com/OCA/partner-contact",
+ "author": "Open Source Integrators, " "Odoo Community Association (OCA)",
+ "category": "Partner Management",
+ "depends": ["partner_firstname"],
+ "data": ["views/res_partner.xml", "views/res_user.xml"],
+ "installable": True,
+}
diff --git a/partner_middlename/models/__init__.py b/partner_middlename/models/__init__.py
new file mode 100644
index 00000000000..0c4235dd497
--- /dev/null
+++ b/partner_middlename/models/__init__.py
@@ -0,0 +1,5 @@
+# Copyright (C) 2023 Open Source Integrators
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
+
+from . import res_config_settings
+from . import res_partner
diff --git a/partner_middlename/models/res_config_settings.py b/partner_middlename/models/res_config_settings.py
new file mode 100644
index 00000000000..b22d9c9e6ac
--- /dev/null
+++ b/partner_middlename/models/res_config_settings.py
@@ -0,0 +1,34 @@
+# Copyright (C) 2023 Open Source Integrators
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
+
+from odoo import models
+
+
+class ResConfigSettings(models.TransientModel):
+ _inherit = "res.config.settings"
+
+ def _partner_names_order_selection(self):
+ options = super()._partner_names_order_selection()
+ new_labels = {
+ "last_first": "Firstname Middlename Lastname",
+ "last_first_comma": "Lastname, Firstname Middlename",
+ }
+ return [(k, new_labels[k]) if k in new_labels else (k, v) for k, v in options]
+
+ def _partners_for_recalculating(self):
+ return self.env["res.partner"].search(
+ [
+ ("is_company", "=", False),
+ "|",
+ "&",
+ ("firstname", "!=", False),
+ ("lastname", "!=", False),
+ "|",
+ "&",
+ ("firstname", "!=", False),
+ ("middlename", "!=", False),
+ "&",
+ ("lastname", "!=", False),
+ ("middlename", "!=", False),
+ ]
+ )
diff --git a/partner_middlename/models/res_partner.py b/partner_middlename/models/res_partner.py
new file mode 100644
index 00000000000..7976870fe8e
--- /dev/null
+++ b/partner_middlename/models/res_partner.py
@@ -0,0 +1,119 @@
+# Copyright (C) 2023 Open Source Integrators
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
+
+from odoo import api, fields, models
+
+from odoo.addons.partner_firstname import exceptions
+
+
+class ResPartner(models.Model):
+ _inherit = "res.partner"
+
+ middlename = fields.Char("Middle Name")
+
+ @api.model
+ def _get_computed_name(self, lastname, firstname, middlename=None):
+ """Compute the name combined with the second lastname too.
+
+ We have 2 lastnames, so lastnames and firstname will be separated by a
+ comma.
+ """
+ order = self._get_names_order()
+ names = list()
+ if order == "last_first":
+ if firstname:
+ names.append(firstname)
+ if middlename:
+ names.append(middlename)
+ if lastname:
+ names.append(lastname)
+ else:
+ if lastname:
+ names.append(lastname)
+ if names and firstname and order == "last_first_comma":
+ names[-1] = names[-1] + ","
+ if firstname:
+ names.append(firstname)
+ if middlename:
+ names.append(middlename)
+ return " ".join(names)
+
+ @api.depends("firstname", "lastname", "middlename")
+ def _compute_name(self):
+ """Write :attr:`~.name` according to splitted data."""
+ for partner in self:
+ partner.name = self._get_computed_name(
+ partner.lastname,
+ partner.firstname,
+ partner.middlename,
+ )
+
+ def _inverse_name(self):
+ """Try to revert the effect of :meth:`._compute_name`."""
+ self.ensure_one()
+ parts = self._get_inverse_name(self.name, self.is_company)
+ # Avoid to hit :meth:`~._check_name` with all 3 fields being ``False``
+ before, after = {}, {}
+ for key, value in parts.items():
+ (before if value else after)[key] = value
+ if any([before[k] != self[k] for k in list(before.keys())]):
+ self.update(before)
+ if any([after[k] != self[k] for k in list(after.keys())]):
+ self.update(after)
+
+ @api.model
+ def _get_inverse_name(self, name, is_company=False):
+ """Compute the inverted name.
+
+ - If the partner is a company, save it in the lastname.
+ - Otherwise, make a guess.
+ """
+ result = {
+ "firstname": False,
+ "lastname": name or False,
+ "middlename": False,
+ }
+
+ # Company name goes to the lastname
+ if not name or is_company:
+ return result
+
+ order = self._get_names_order()
+ result.update(super()._get_inverse_name(name, is_company))
+
+ if order in ("last_first", "last_first_comma"):
+ parts = self._split_part("lastname", result)
+ if parts:
+ result.update({"lastname": parts[0], "middlename": " ".join(parts[1:])})
+ else:
+ parts = self._split_part("firstname", result)
+ if parts:
+ result.update(
+ {"firstname": parts[-1], "middlename": " ".join(parts[:-1])}
+ )
+ return result
+
+ def _split_part(self, name_part, name_split):
+ """Split a given part of a name.
+
+ :param name_split: The parts of the name
+ :type dict
+
+ :param name_part: The part to split
+ :type str
+ """
+ name = name_split.get(name_part, False)
+ parts = name.split(" ", 1) if name else []
+ if not name or len(parts) < 2:
+ return False
+ return parts
+
+ @api.constrains("firstname", "lastname", "middlename")
+ def _check_name(self):
+ """Ensure at least one name is set."""
+ try:
+ return super()._check_name()
+ except exceptions.EmptyNamesError:
+ for partner in self:
+ if not partner.middlename:
+ raise
diff --git a/partner_middlename/readme/CONFIGURE.rst b/partner_middlename/readme/CONFIGURE.rst
new file mode 100644
index 00000000000..7251cafe1a8
--- /dev/null
+++ b/partner_middlename/readme/CONFIGURE.rst
@@ -0,0 +1 @@
+At Settings / General Settings / Partner Names Order, select option "Firstname Middlename Lastname" or " Lastname, Firstname Middlename".
diff --git a/partner_middlename/readme/CONTRIBUTORS.rst b/partner_middlename/readme/CONTRIBUTORS.rst
new file mode 100644
index 00000000000..f25441b9e8d
--- /dev/null
+++ b/partner_middlename/readme/CONTRIBUTORS.rst
@@ -0,0 +1,3 @@
+* `Open Source Integrators `_:
+ * Daniel Reis
+ * Nikul Chaudhary
diff --git a/partner_middlename/readme/DESCRIPTION.rst b/partner_middlename/readme/DESCRIPTION.rst
new file mode 100644
index 00000000000..7b7b7230f88
--- /dev/null
+++ b/partner_middlename/readme/DESCRIPTION.rst
@@ -0,0 +1 @@
+Allows to enter contact names using three separate fields, for First name, Middle Name and Last Name.
diff --git a/partner_middlename/readme/USAGE.rst b/partner_middlename/readme/USAGE.rst
new file mode 100644
index 00000000000..68e4d14884f
--- /dev/null
+++ b/partner_middlename/readme/USAGE.rst
@@ -0,0 +1,5 @@
+On the Contact form, create a new contact.
+
+* Set contact to "Individual". The full name will not be directly editable.
+* Set all or any of the First Name, Middle name and Last Name fields.
+* The full name should be automatically populated based on the name fields set, and the general setting selected.
diff --git a/partner_middlename/static/description/icon.png b/partner_middlename/static/description/icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..3a0328b516c4980e8e44cdb63fd945757ddd132d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ha1wx#SCgwmn*{w2TRX*I
literal 0
HcmV?d00001
diff --git a/partner_middlename/views/res_partner.xml b/partner_middlename/views/res_partner.xml
new file mode 100644
index 00000000000..2f06a8f9d10
--- /dev/null
+++ b/partner_middlename/views/res_partner.xml
@@ -0,0 +1,80 @@
+
+
+
+ res.partner
+
+
+
+
+ {'required': [('lastname', '=', False), ('middlename', '=', False),
+ ('is_company', '=', False), ('type', '=', 'contact')]}
+
+
+
+
+ {'required': [('firstname', '=', False), ('middlename', '=', False),
+ ('is_company', '=', False), ('type', '=', 'contact')]}
+
+
+
+
+
+
+
+
+ res.partner
+
+
+
+
+
+ {'required': [('lastname', '=', False), ('middlename', '=', False),
+ ('is_company', '=', False), ('type', '=', 'contact')]}
+
+
+
+
+ {'required': [('firstname', '=', False), ('middlename', '=', False),
+ ('is_company', '=', False), ('type', '=', 'contact')]}
+
+
+
+
+
+
+
+
+ {'required': [('lastname', '=', False), ('middlename', '=', False),
+ ('is_company', '=', False), ('type', '=', 'contact')]}
+
+
+
+
+ {'required': [('firstname', '=', False), ('middlename', '=', False),
+ ('is_company', '=', False), ('type', '=', 'contact')]}
+
+
+
+
+
+
+
+
diff --git a/partner_middlename/views/res_user.xml b/partner_middlename/views/res_user.xml
new file mode 100644
index 00000000000..e976af1a9b9
--- /dev/null
+++ b/partner_middlename/views/res_user.xml
@@ -0,0 +1,26 @@
+
+
+
+ Add second last name
+ res.users
+
+
+
+
+ {'required': [('lastname', '=', False), ('middlename', '=', False)]}
+
+
+
+
+ {'required': [('firstname', '=', False), ('middlename', '=', False)]}
+
+
+
+
+
+
+
+
From ef99c420347a8c433ba5ec3110876e49a257921c Mon Sep 17 00:00:00 2001
From: Daniel Reis
Date: Tue, 18 Apr 2023 15:26:25 +0100
Subject: [PATCH 02/14] [FIX] partner_middlename: add to rebel module list
---
partner_middlename/readme/DESCRIPTION.rst | 3 +++
1 file changed, 3 insertions(+)
diff --git a/partner_middlename/readme/DESCRIPTION.rst b/partner_middlename/readme/DESCRIPTION.rst
index 7b7b7230f88..a7ef6761899 100644
--- a/partner_middlename/readme/DESCRIPTION.rst
+++ b/partner_middlename/readme/DESCRIPTION.rst
@@ -1 +1,4 @@
Allows to enter contact names using three separate fields, for First name, Middle Name and Last Name.
+
+NOTE: currently this feature is incompatible with te Partner Second Last Name (``partner_second_lastname``),
+please don't install them together in the same database.
From 13bd0a8e1e65df63ba6373227bca97382a047e65 Mon Sep 17 00:00:00 2001
From: Nikul-OSI
Date: Wed, 19 Apr 2023 14:38:55 +0530
Subject: [PATCH 03/14] [FIX] Fixed code and Added a unit test case
---
partner_middlename/README.rst | 120 +-----------------
.../models/res_config_settings.py | 8 --
partner_middlename/models/res_partner.py | 37 +++---
partner_middlename/tests/__init__.py | 5 +
partner_middlename/tests/test_config.py | 32 +++++
partner_middlename/tests/test_name.py | 114 +++++++++++++++++
6 files changed, 171 insertions(+), 145 deletions(-)
create mode 100644 partner_middlename/tests/__init__.py
create mode 100644 partner_middlename/tests/test_config.py
create mode 100644 partner_middlename/tests/test_name.py
diff --git a/partner_middlename/README.rst b/partner_middlename/README.rst
index a1f27282983..0d7429afc0d 100644
--- a/partner_middlename/README.rst
+++ b/partner_middlename/README.rst
@@ -1,119 +1 @@
-========================
-Partner second last name
-========================
-
-.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- !! This file is generated by oca-gen-addon-readme !!
- !! changes will be overwritten. !!
- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-.. |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%2Fpartner--contact-lightgray.png?logo=github
- :target: https://github.com/OCA/partner-contact/tree/16.0/partner_second_lastname
- :alt: OCA/partner-contact
-.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
- :target: https://translation.odoo-community.org/projects/partner-contact-16-0/partner-contact-16-0-partner_second_lastname
- :alt: Translate me on Weblate
-.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
- :target: https://runbot.odoo-community.org/runbot/134/16.0
- :alt: Try me on Runbot
-
-|badge1| |badge2| |badge3| |badge4| |badge5|
-
-This module was written to extend the functionality of ``partner_firstname`` to
-support having a second lastname for contact partners.
-
-In some countries, it's important to have a second last name for contacts.
-
-Contact partners will need to fill at least one of the name fields
-(*First name*, *First last name* or *Second last name*).
-
-**Table of contents**
-
-.. contents::
- :local:
-
-Configuration
-=============
-
-You can configure some common name patterns for the inverse function
-in Settings > Configuration > General settings:
-
-* Lastname SecondLastname Firstname: For example 'Anderson Lavarge Robert'
-* Lastname SecondLastname, Firstname: For example 'Anderson Lavarge, Robert'
-* Firstname Lastname SecondLastname: For example 'Robert Anderson Lavarge'
-
-After applying the changes, you can recalculate all partners name clicking
-"Recalculate names" button. Note: This process could take so much time depending
-how many partners there are in database.
-
-You can use *_get_inverse_name* method to get firstname, lastname and
-second lastname from a simple string and also *_get_computed_name* to get a
-name form the firstname, lastname and second lastname.
-These methods can be overridden to change the format specified above.
-
-Usage
-=====
-
-To use this module, you need to:
-
-* Edit any partner's form.
-* Make sure the partner is not a company.
-* Enter firstname and lastnames.
-
-If you directly enter the full name instead of entering the other fields
-separately (maybe from other form), this module will try to guess the best
-match for your input and split it between firstname, lastname and second
-lastname using an inverse function.
-
-If you can, always enter it manually please. Automatic guessing could fail for
-you easily in some corner cases.
-
-Bug Tracker
-===========
-
-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 smashing it by providing a detailed and welcomed
-`feedback `_.
-
-Do not contact contributors directly about support or help with technical issues.
-
-Credits
-=======
-
-Authors
-~~~~~~~
-
-* Tecnativa
-
-Contributors
-~~~~~~~~~~~~
-
-* Jairo Llopis .
-* Antonio Espinosa.
-* Pedro M. Baeza .
-* Nikul Chaudhary
-* Manuel Regidor
-
-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.
-
-This module is part of the `OCA/partner-contact `_ project on GitHub.
-
-You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
+AUTOMATICALLY GENERATED
diff --git a/partner_middlename/models/res_config_settings.py b/partner_middlename/models/res_config_settings.py
index b22d9c9e6ac..33308ca7fa7 100644
--- a/partner_middlename/models/res_config_settings.py
+++ b/partner_middlename/models/res_config_settings.py
@@ -7,14 +7,6 @@
class ResConfigSettings(models.TransientModel):
_inherit = "res.config.settings"
- def _partner_names_order_selection(self):
- options = super()._partner_names_order_selection()
- new_labels = {
- "last_first": "Firstname Middlename Lastname",
- "last_first_comma": "Lastname, Firstname Middlename",
- }
- return [(k, new_labels[k]) if k in new_labels else (k, v) for k, v in options]
-
def _partners_for_recalculating(self):
return self.env["res.partner"].search(
[
diff --git a/partner_middlename/models/res_partner.py b/partner_middlename/models/res_partner.py
index 7976870fe8e..292ec5f4882 100644
--- a/partner_middlename/models/res_partner.py
+++ b/partner_middlename/models/res_partner.py
@@ -13,30 +13,25 @@ class ResPartner(models.Model):
@api.model
def _get_computed_name(self, lastname, firstname, middlename=None):
- """Compute the name combined with the second lastname too.
-
- We have 2 lastnames, so lastnames and firstname will be separated by a
- comma.
- """
+ """Compute the 'name' field according to splitted data.
+ You can override this method to change the order of lastname and
+ firstname and middlename the computed name"""
order = self._get_names_order()
- names = list()
- if order == "last_first":
- if firstname:
- names.append(firstname)
- if middlename:
- names.append(middlename)
- if lastname:
- names.append(lastname)
- else:
+ if order == "last_first_comma":
+ names = list()
if lastname:
names.append(lastname)
- if names and firstname and order == "last_first_comma":
+ if names and firstname:
names[-1] = names[-1] + ","
if firstname:
names.append(firstname)
if middlename:
names.append(middlename)
- return " ".join(names)
+ return " ".join(names)
+ elif order == "first_last":
+ return " ".join(p for p in (firstname, middlename, lastname) if p)
+ else:
+ return " ".join(p for p in (lastname, firstname, middlename) if p)
@api.depends("firstname", "lastname", "middlename")
def _compute_name(self):
@@ -81,10 +76,16 @@ def _get_inverse_name(self, name, is_company=False):
order = self._get_names_order()
result.update(super()._get_inverse_name(name, is_company))
- if order in ("last_first", "last_first_comma"):
+ if order == "first_last":
parts = self._split_part("lastname", result)
if parts:
- result.update({"lastname": parts[0], "middlename": " ".join(parts[1:])})
+ result.update({"middlename": parts[0], "lastname": " ".join(parts[1:])})
+ elif order == "last_first_comma":
+ parts = self._split_part("firstname", result)
+ if parts:
+ result.update(
+ {"firstname": parts[0], "middlename": " ".join(parts[1:])}
+ )
else:
parts = self._split_part("firstname", result)
if parts:
diff --git a/partner_middlename/tests/__init__.py b/partner_middlename/tests/__init__.py
new file mode 100644
index 00000000000..4b950899b0a
--- /dev/null
+++ b/partner_middlename/tests/__init__.py
@@ -0,0 +1,5 @@
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
+
+from . import test_name
+from . import test_config
+from odoo.addons.partner_firstname.tests import test_empty
diff --git a/partner_middlename/tests/test_config.py b/partner_middlename/tests/test_config.py
new file mode 100644
index 00000000000..49cea5c81ac
--- /dev/null
+++ b/partner_middlename/tests/test_config.py
@@ -0,0 +1,32 @@
+# Copyright 2017 Tecnativa - Pedro M. Baeza
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
+
+from odoo.tests.common import TransactionCase
+
+
+class TestConfig(TransactionCase):
+ @classmethod
+ def setUpClass(cls):
+ super().setUpClass()
+ cls.wizard = cls.env["res.config.settings"].create({})
+ cls.partner = cls.env["res.partner"].create(
+ {"firstname": "First", "middlename": "Middle", "lastname": "Last"}
+ )
+
+ def test_last_first(self):
+ self.wizard.partner_names_order = "last_first"
+ self.wizard.set_values()
+ self.wizard.action_recalculate_partners_name()
+ self.assertEqual(self.partner.name, "Last First Middle")
+
+ def test_last_first_comma(self):
+ self.wizard.partner_names_order = "last_first_comma"
+ self.wizard.set_values()
+ self.wizard.action_recalculate_partners_name()
+ self.assertEqual(self.partner.name, "Last, First Middle")
+
+ def test_first_last(self):
+ self.wizard.partner_names_order = "first_last"
+ self.wizard.set_values()
+ self.wizard.action_recalculate_partners_name()
+ self.assertEqual(self.partner.name, "First Middle Last")
diff --git a/partner_middlename/tests/test_name.py b/partner_middlename/tests/test_name.py
new file mode 100644
index 00000000000..187d64c8588
--- /dev/null
+++ b/partner_middlename/tests/test_name.py
@@ -0,0 +1,114 @@
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
+# Copyright 2015 Grupo ESOC Ingeniería de Servicios, S.L.U.
+# Copyright 2015 Antiun Ingenieria S.L. - Antonio Espinosa
+
+from odoo.tests.common import TransactionCase
+
+from odoo.addons.partner_firstname.tests.base import MailInstalled
+
+
+class PersonCase(TransactionCase):
+ """Test ``res.partner`` when it is a person."""
+
+ model = "res.partner"
+ context = dict()
+
+ def setUp(self):
+ super().setUp()
+ self.env["ir.config_parameter"].set_param(
+ "partner_names_order", "last_first_comma"
+ )
+
+ self.firstname = "Fírstname"
+ self.middlename = "Middlename"
+ self.lastname = "Làstname1"
+ self.template = "%(last1)s %(first)s, %(last2)s"
+
+ def tearDown(self):
+ try:
+ new = self.env[self.model].with_context(**self.context).create(self.params)
+
+ # Check that each individual field matches
+ self.assertEqual(self.firstname, new.firstname, "First name saved badly.")
+ self.assertEqual(self.lastname, new.lastname, "Last name 1 saved badly.")
+ self.assertEqual(
+ self.middlename, new.middlename, "Middle name saved badly."
+ )
+
+ # Check that name gets saved fine
+ self.assertEqual(
+ self.template
+ % (
+ {
+ "first": self.firstname,
+ "last1": self.lastname,
+ "last2": self.middlename,
+ }
+ ),
+ new.name,
+ "Name saved badly.",
+ )
+
+ finally:
+ super().tearDown()
+
+ def test_firstname_first(self):
+ """Create a person setting his first name first."""
+ self.env["ir.config_parameter"].set_param("partner_names_order", "first_last")
+ self.template = "%(first)s %(last2)s %(last1)s"
+ self.params = {
+ "is_company": False,
+ "name": "{} {} {}".format(self.firstname, self.middlename, self.lastname),
+ }
+
+ def test_firstname_last_wo_comma(self):
+ """Create a person setting his first name last and the order as 'last_first'"""
+ self.env["ir.config_parameter"].set_param("partner_names_order", "last_first")
+ self.template = "%(last1)s %(first)s %(last2)s"
+ self.params = {
+ "is_company": False,
+ "name": "{} {} {}".format(self.lastname, self.middlename, self.firstname),
+ }
+
+ def test_firstname_only(self):
+ """Create a person setting his first name only."""
+ self.env["ir.config_parameter"].set_param("partner_names_order", "first_last")
+ self.firstname = self.middlename = False
+ self.template = "%(last1)s"
+ self.params = {
+ "is_company": False,
+ "name": self.lastname,
+ }
+
+ def test_firstname_lastname_only(self):
+ """Create a person setting his first name and last name 1 only."""
+ self.env["ir.config_parameter"].set_param("partner_names_order", "first_last")
+ self.middlename = False
+ self.template = "%(first)s %(last1)s"
+ self.params = {
+ "is_company": False,
+ "name": "{} {}".format(self.firstname, self.lastname),
+ }
+
+ def test_lastname_firstname_only_wo_comma(self):
+ """Create a person setting his last name 1 and first name only.
+ Set order to 'last_first' to test name split without comma"""
+ self.env["ir.config_parameter"].set_param("partner_names_order", "last_first")
+ self.middlename = False
+ self.template = "%(last1)s %(first)s"
+ self.params = {
+ "is_company": False,
+ "name": "{} {}".format(self.lastname, self.firstname),
+ }
+
+
+class UserCase(PersonCase, MailInstalled):
+ """Test ``res.users``."""
+
+ model = "res.users"
+ context = {"default_login": "user@example.com"}
+
+ def tearDown(self):
+ # Skip if ``mail`` is installed
+ if not self.mail_installed():
+ super().tearDown()
From 107e9533a9ac319dabdb26d04f3bbeac59b8cd70 Mon Sep 17 00:00:00 2001
From: oca-ci
Date: Sat, 22 Apr 2023 17:00:17 +0000
Subject: [PATCH 04/14] [UPD] Update partner_middlename.pot
---
.../i18n/partner_middlename.pot | 30 +++++++++++++++++++
1 file changed, 30 insertions(+)
create mode 100644 partner_middlename/i18n/partner_middlename.pot
diff --git a/partner_middlename/i18n/partner_middlename.pot b/partner_middlename/i18n/partner_middlename.pot
new file mode 100644
index 00000000000..dbe5754ef6f
--- /dev/null
+++ b/partner_middlename/i18n/partner_middlename.pot
@@ -0,0 +1,30 @@
+# Translation of Odoo Server.
+# This file contains the translation of the following modules:
+# * partner_middlename
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: Odoo Server 16.0\n"
+"Report-Msgid-Bugs-To: \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: partner_middlename
+#: model:ir.model,name:partner_middlename.model_res_config_settings
+msgid "Config Settings"
+msgstr ""
+
+#. module: partner_middlename
+#: model:ir.model,name:partner_middlename.model_res_partner
+msgid "Contact"
+msgstr ""
+
+#. module: partner_middlename
+#: model:ir.model.fields,field_description:partner_middlename.field_res_partner__middlename
+#: model:ir.model.fields,field_description:partner_middlename.field_res_users__middlename
+msgid "Middle Name"
+msgstr ""
From de1222ab10cfc820a7a0cf85bc3e83afbb7ea341 Mon Sep 17 00:00:00 2001
From: OCA-git-bot
Date: Sat, 22 Apr 2023 17:03:26 +0000
Subject: [PATCH 05/14] [UPD] README.rst
---
partner_middlename/README.rst | 93 +++-
.../static/description/index.html | 438 ++++++++++++++++++
2 files changed, 530 insertions(+), 1 deletion(-)
create mode 100644 partner_middlename/static/description/index.html
diff --git a/partner_middlename/README.rst b/partner_middlename/README.rst
index 0d7429afc0d..8bef9116c2e 100644
--- a/partner_middlename/README.rst
+++ b/partner_middlename/README.rst
@@ -1 +1,92 @@
-AUTOMATICALLY GENERATED
+===================
+Partner Middle Name
+===================
+
+.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ !! This file is generated by oca-gen-addon-readme !!
+ !! changes will be overwritten. !!
+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+.. |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%2Fpartner--contact-lightgray.png?logo=github
+ :target: https://github.com/OCA/partner-contact/tree/16.0/partner_middlename
+ :alt: OCA/partner-contact
+.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
+ :target: https://translation.odoo-community.org/projects/partner-contact-16-0/partner-contact-16-0-partner_middlename
+ :alt: Translate me on Weblate
+.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
+ :target: https://runbot.odoo-community.org/runbot/134/16.0
+ :alt: Try me on Runbot
+
+|badge1| |badge2| |badge3| |badge4| |badge5|
+
+Allows to enter contact names using three separate fields, for First name, Middle Name and Last Name.
+
+NOTE: currently this feature is incompatible with te Partner Second Last Name (``partner_second_lastname``),
+please don't install them together in the same database.
+
+**Table of contents**
+
+.. contents::
+ :local:
+
+Configuration
+=============
+
+At Settings / General Settings / Partner Names Order, select option "Firstname Middlename Lastname" or " Lastname, Firstname Middlename".
+
+Usage
+=====
+
+On the Contact form, create a new contact.
+
+* Set contact to "Individual". The full name will not be directly editable.
+* Set all or any of the First Name, Middle name and Last Name fields.
+* The full name should be automatically populated based on the name fields set, and the general setting selected.
+
+Bug Tracker
+===========
+
+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 smashing it by providing a detailed and welcomed
+`feedback `_.
+
+Do not contact contributors directly about support or help with technical issues.
+
+Credits
+=======
+
+Authors
+~~~~~~~
+
+* Open Source Integrators
+
+Contributors
+~~~~~~~~~~~~
+
+* `Open Source Integrators `_:
+ * Daniel Reis
+ * Nikul Chaudhary
+
+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.
+
+This module is part of the `OCA/partner-contact `_ project on GitHub.
+
+You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
diff --git a/partner_middlename/static/description/index.html b/partner_middlename/static/description/index.html
new file mode 100644
index 00000000000..102f946bb7d
--- /dev/null
+++ b/partner_middlename/static/description/index.html
@@ -0,0 +1,438 @@
+
+
+
+
+
+
+Partner Middle Name
+
+
+
+
+
Partner Middle Name
+
+
+

+
Allows to enter contact names using three separate fields, for First name, Middle Name and Last Name.
+
NOTE: currently this feature is incompatible with te Partner Second Last Name (partner_second_lastname),
+please don’t install them together in the same database.
+
Table of contents
+
+
+
+
At Settings / General Settings / Partner Names Order, select option “Firstname Middlename Lastname” or ” Lastname, Firstname Middlename”.
+
+
+
+
On the Contact form, create a new contact.
+
+- Set contact to “Individual”. The full name will not be directly editable.
+- Set all or any of the First Name, Middle name and Last Name fields.
+- The full name should be automatically populated based on the name fields set, and the general setting selected.
+
+
+
+
+
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 smashing it by providing a detailed and welcomed
+feedback.
+
Do not contact contributors directly about support or help with technical issues.
+
+
+
+
+
+
+- Open Source Integrators
+
+
+
+
+
+
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/partner-contact project on GitHub.
+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
+
+
+
+
+
From fbb0a7ad675a65e8a7b53c7c396cf6b19d099ac5 Mon Sep 17 00:00:00 2001
From: OCA-git-bot
Date: Sun, 3 Sep 2023 15:04:50 +0000
Subject: [PATCH 06/14] [UPD] README.rst
---
partner_middlename/README.rst | 15 ++++---
.../static/description/index.html | 44 ++++++++++---------
2 files changed, 32 insertions(+), 27 deletions(-)
diff --git a/partner_middlename/README.rst b/partner_middlename/README.rst
index 8bef9116c2e..d14e3768f81 100644
--- a/partner_middlename/README.rst
+++ b/partner_middlename/README.rst
@@ -2,10 +2,13 @@
Partner Middle Name
===================
-.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+..
+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ !! source digest: sha256:f407050c966c319987c0347ba93ce0a90932ed250921016146f1a14b80c9dfca
+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
@@ -19,11 +22,11 @@ Partner Middle Name
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/partner-contact-16-0/partner-contact-16-0-partner_middlename
:alt: Translate me on Weblate
-.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
- :target: https://runbot.odoo-community.org/runbot/134/16.0
- :alt: Try me on Runbot
+.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
+ :target: https://runboat.odoo-community.org/builds?repo=OCA/partner-contact&target_branch=16.0
+ :alt: Try me on Runboat
-|badge1| |badge2| |badge3| |badge4| |badge5|
+|badge1| |badge2| |badge3| |badge4| |badge5|
Allows to enter contact names using three separate fields, for First name, Middle Name and Last Name.
@@ -54,7 +57,7 @@ Bug Tracker
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 smashing it by providing a detailed and welcomed
+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.
diff --git a/partner_middlename/static/description/index.html b/partner_middlename/static/description/index.html
index 102f946bb7d..987fecdb097 100644
--- a/partner_middlename/static/description/index.html
+++ b/partner_middlename/static/description/index.html
@@ -1,20 +1,20 @@
-
+
-
+
Partner Middle Name
-
-
Partner Middle Name
+
+
+
+
+
+
+
Partner Middle Name
-

+

Allows to enter contact names using three separate fields, for First
name, Middle Name and Last Name.
NOTE: currently this feature is incompatible with te Partner Second Last
@@ -390,12 +395,12 @@
Partner Middle Name
-
+
At Settings / General Settings / Partner Names Order, select option
“Firstname Middlename Lastname” or “ Lastname, Firstname Middlename”.
-
+
On the Contact form, create a new contact.
- Set contact to “Individual”. The full name will not be directly
@@ -406,7 +411,7 @@
-
+
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
@@ -414,15 +419,15 @@
Do not contact contributors directly about support or help with technical issues.
+
From 0c22ed4fcdf919453fd551fd8911d9797b0b2e6a Mon Sep 17 00:00:00 2001
From: Maxime Franco
Date: Fri, 22 May 2026 09:37:34 +0200
Subject: [PATCH 13/14] [IMP] partner_middlename: pre-commit auto fixes
---
partner_middlename/__manifest__.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/partner_middlename/__manifest__.py b/partner_middlename/__manifest__.py
index 569caad0305..8485232297c 100644
--- a/partner_middlename/__manifest__.py
+++ b/partner_middlename/__manifest__.py
@@ -7,7 +7,7 @@
"version": "18.0.1.0.0",
"license": "AGPL-3",
"website": "https://github.com/OCA/partner-contact",
- "author": "Open Source Integrators, " "Odoo Community Association (OCA)",
+ "author": "Open Source Integrators, Odoo Community Association (OCA)",
"category": "Partner Management",
"depends": ["partner_firstname"],
"data": ["views/res_partner.xml", "views/res_user.xml"],
From 6df0b7094d6d2715f199637984df438496e88b6b Mon Sep 17 00:00:00 2001
From: Maxime Franco
Date: Fri, 22 May 2026 10:30:13 +0200
Subject: [PATCH 14/14] [MIG] partner_middlename: Migration to 19.0
---
partner_middlename/README.rst | 14 +++++++++-----
partner_middlename/__manifest__.py | 2 +-
partner_middlename/models/res_partner.py | 4 ++--
partner_middlename/readme/CONTRIBUTORS.md | 2 ++
partner_middlename/static/description/index.html | 10 +++++++---
5 files changed, 21 insertions(+), 11 deletions(-)
diff --git a/partner_middlename/README.rst b/partner_middlename/README.rst
index 340fbf22c6a..1f5aa60cd43 100644
--- a/partner_middlename/README.rst
+++ b/partner_middlename/README.rst
@@ -21,13 +21,13 @@ Partner Middle Name
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpartner--contact-lightgray.png?logo=github
- :target: https://github.com/OCA/partner-contact/tree/18.0/partner_middlename
+ :target: https://github.com/OCA/partner-contact/tree/19.0/partner_middlename
:alt: OCA/partner-contact
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
- :target: https://translation.odoo-community.org/projects/partner-contact-18-0/partner-contact-18-0-partner_middlename
+ :target: https://translation.odoo-community.org/projects/partner-contact-19-0/partner-contact-19-0-partner_middlename
: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/partner-contact&target_branch=18.0
+ :target: https://runboat.odoo-community.org/builds?repo=OCA/partner-contact&target_branch=19.0
:alt: Try me on Runboat
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -67,7 +67,7 @@ Bug Tracker
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 `_.
+`feedback `_.
Do not contact contributors directly about support or help with technical issues.
@@ -91,6 +91,10 @@ Contributors
- Bhavesh Heliconia
+- `ACSONE SA/NV `__
+
+ - Maxime Franco
+
Maintainers
-----------
@@ -104,6 +108,6 @@ 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/partner-contact `_ project on GitHub.
+This module is part of the `OCA/partner-contact `_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
diff --git a/partner_middlename/__manifest__.py b/partner_middlename/__manifest__.py
index 8485232297c..ece8705cece 100644
--- a/partner_middlename/__manifest__.py
+++ b/partner_middlename/__manifest__.py
@@ -4,7 +4,7 @@
{
"name": "Partner Middle Name",
"summary": "Have split Middle",
- "version": "18.0.1.0.0",
+ "version": "19.0.1.0.0",
"license": "AGPL-3",
"website": "https://github.com/OCA/partner-contact",
"author": "Open Source Integrators, Odoo Community Association (OCA)",
diff --git a/partner_middlename/models/res_partner.py b/partner_middlename/models/res_partner.py
index 292ec5f4882..d1e3c2dd68b 100644
--- a/partner_middlename/models/res_partner.py
+++ b/partner_middlename/models/res_partner.py
@@ -110,10 +110,10 @@ def _split_part(self, name_part, name_split):
return parts
@api.constrains("firstname", "lastname", "middlename")
- def _check_name(self):
+ def _check_firstname_lastname(self):
"""Ensure at least one name is set."""
try:
- return super()._check_name()
+ return super()._check_firstname_lastname()
except exceptions.EmptyNamesError:
for partner in self:
if not partner.middlename:
diff --git a/partner_middlename/readme/CONTRIBUTORS.md b/partner_middlename/readme/CONTRIBUTORS.md
index 0754fea5a89..6266a3803d2 100644
--- a/partner_middlename/readme/CONTRIBUTORS.md
+++ b/partner_middlename/readme/CONTRIBUTORS.md
@@ -3,3 +3,5 @@
- Nikul Chaudhary \<\>
- [Heliconia Solutions Pvt. Ltd.](https://www.heliconia.io)
- Bhavesh Heliconia
+- [ACSONE SA/NV](https://https://www.acsone.eu/)
+ - Maxime Franco \<\>
diff --git a/partner_middlename/static/description/index.html b/partner_middlename/static/description/index.html
index 70c6bdfec3b..781b775990b 100644
--- a/partner_middlename/static/description/index.html
+++ b/partner_middlename/static/description/index.html
@@ -374,7 +374,7 @@ Partner Middle Name
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:2900aece401268fdb58ee940febf3f98852d89e4e490ab88f213ef767038368d
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
-

+

Allows to enter contact names using three separate fields, for First
name, Middle Name and Last Name.
NOTE: currently this feature is incompatible with te Partner Second Last
@@ -415,7 +415,7 @@
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.
+feedback.
Do not contact contributors directly about support or help with technical issues.
@@ -449,7 +453,7 @@
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/partner-contact project on GitHub.
+
This module is part of the OCA/partner-contact project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.