Skip to content

Commit

Permalink
[MIG] partner_firstname: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Joachim David committed Oct 14, 2024
1 parent 94e7766 commit f927a3e
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 28 deletions.
10 changes: 5 additions & 5 deletions partner_firstname/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ Partner first name and last 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/17.0/partner_firstname
:target: https://github.com/OCA/partner-contact/tree/18.0/partner_firstname
: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-17-0/partner-contact-17-0-partner_firstname
:target: https://translation.odoo-community.org/projects/partner-contact-18-0/partner-contact-18-0-partner_firstname
: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=17.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/partner-contact&target_branch=18.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand Down Expand Up @@ -89,7 +89,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/partner-contact/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/partner-contact/issues/new?body=module:%20partner_firstname%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/partner-contact/issues/new?body=module:%20partner_firstname%0Aversion:%2018.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.

Expand Down Expand Up @@ -146,6 +146,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 <https://github.com/OCA/partner-contact/tree/17.0/partner_firstname>`_ project on GitHub.
This module is part of the `OCA/partner-contact <https://github.com/OCA/partner-contact/tree/18.0/partner_firstname>`_ 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 partner_firstname/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{
"name": "Partner first name and last name",
"summary": "Split first name and last name for non company partners",
"version": "17.0.1.0.3",
"version": "18.0.1.0.0",
"author": "Camptocamp, "
"Grupo ESOC Ingeniería de Servicios, "
"Tecnativa, "
Expand Down
19 changes: 6 additions & 13 deletions partner_firstname/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,16 @@ def create(self, vals_list):
created_partners = self.browse()
for vals in vals_list:
partner_context = dict(self.env.context)
if (
not vals.get("is_company")
and self.name_fields_in_vals(vals)
and "name" in vals
):
is_company = vals.get("company_type") == "company"
if not is_company and self.name_fields_in_vals(vals) and "name" in vals:
del vals["name"]
partner_context.pop("default_name", None)
else:
name = vals.get("name", partner_context.get("default_name"))
if name is not None:
# Calculate the split fields
inverted = self._get_inverse_name(
self._get_whitespace_cleaned_name(name),
vals.get(
"is_company", self.default_get(["is_company"])["is_company"]
),
self._get_whitespace_cleaned_name(name), is_company
)
for key, value in inverted.items():
if not vals.get(key) or partner_context.get("copy"):
Expand Down Expand Up @@ -101,10 +95,9 @@ def copy(self, default=None):
and lastname fields.
"""
default = default or {}
if not self.is_company:
order = self._get_names_order()
extra_default_values = self.get_extra_default_copy_values(order)
default.update(extra_default_values)
order = self._get_names_order()
extra_default_values = self.get_extra_default_copy_values(order)
default.update(extra_default_values)
return super(ResPartner, self.with_context(copy=True)).copy(default)

@api.model
Expand Down
6 changes: 3 additions & 3 deletions partner_firstname/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ <h1 class="title">Partner first name and last name</h1>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:43d730c51ef59b1c6de4109020507234da1ada647d1a04e2b0bc1dc74dad4451
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/partner-contact/tree/17.0/partner_firstname"><img alt="OCA/partner-contact" src="https://img.shields.io/badge/github-OCA%2Fpartner--contact-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/partner-contact-17-0/partner-contact-17-0-partner_firstname"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/partner-contact&amp;target_branch=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/partner-contact/tree/18.0/partner_firstname"><img alt="OCA/partner-contact" src="https://img.shields.io/badge/github-OCA%2Fpartner--contact-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/partner-contact-18-0/partner-contact-18-0-partner_firstname"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/partner-contact&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module was written to extend the functionality of contacts to
support having separate last name and first name.</p>
<p><strong>Table of contents</strong></p>
Expand Down Expand Up @@ -433,7 +433,7 @@ <h1><a class="toc-backref" href="#toc-entry-4">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/partner-contact/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/partner-contact/issues/new?body=module:%20partner_firstname%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/partner-contact/issues/new?body=module:%20partner_firstname%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand Down Expand Up @@ -487,7 +487,7 @@ <h2><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h2>
<p>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.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/partner-contact/tree/17.0/partner_firstname">OCA/partner-contact</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/partner-contact/tree/18.0/partner_firstname">OCA/partner-contact</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions partner_firstname/tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ def tearDown(self):
self.assertEqual(
self.changed[field],
getattr(self, field),
"Test failed with wrong %s" % field,
f"Test failed with wrong {field}",
)

super().tearDown()

def test_copy(self):
"""Copy the partner and compare the result."""
self.expect("%s (copy)" % self.lastname, self.firstname)
self.expect(f"{self.lastname} (copy)", self.firstname)
self.changed = self.original.with_context(copy=True, lang="en_US").copy()

def test_one_name(self):
Expand Down
4 changes: 2 additions & 2 deletions partner_firstname/tests/test_copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ def test_copy_multiple_names_company(self):
copy,
[
{
"firstname": False,
"lastname": "Firstname1 Firstname2 Lastname1 Lastname2 (copy)",
"firstname": "Firstname1 Firstname2",
"lastname": "Lastname1 Lastname2 (copy)",
"name": "Firstname1 Firstname2 Lastname1 Lastname2 (copy)",
}
],
Expand Down
2 changes: 1 addition & 1 deletion partner_firstname/tests/test_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def tearDown(self):
self.env[self.model].with_context(**self.context).create(self.values)
)
for key, value in self.good_values.items():
self.assertEqual(self.record[key], value, "Checking key %s" % key)
self.assertEqual(self.record[key], value, f"Checking key {key}")

super().tearDown()

Expand Down
2 changes: 1 addition & 1 deletion partner_firstname/tests/test_defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def setUp(self):

def tearDown(self):
for key, value in self.values.items():
self.assertEqual(self.defaults.get(key), value, "Checking key %s" % key)
self.assertEqual(self.defaults.get(key), value, f"Checking key {key}")

return super().tearDown()

Expand Down
1 change: 1 addition & 0 deletions partner_firstname/tests/test_name.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def test_copy(self):
"""Copy the partner and compare the result."""
res = super().test_copy()
self.expect(self.name, False, self.name)
self.check_fields = False
return res

def test_company_inverse(self):
Expand Down

0 comments on commit f927a3e

Please sign in to comment.