Skip to content

Commit

Permalink
[16.0][FIX] partner_firstname: fix installation w/ missing names
Browse files Browse the repository at this point in the history
Resolve issue blocking partner_firstname from installation

This change fixes this bug: #1677

With that the module can be installed as only partners with names will be processed
  • Loading branch information
mohs8421 committed Nov 15, 2024
1 parent 2d183ca commit 6437657
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 3 additions & 1 deletion partner_firstname/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,9 @@ def _install_partner_firstname(self):
correctly into the database. This can be called later too if needed.
"""
# Find records with empty firstname and lastname
records = self.search([("firstname", "=", False), ("lastname", "=", False)])
records = self.search(

Check warning on line 262 in partner_firstname/models/res_partner.py

View check run for this annotation

Codecov / codecov/patch

partner_firstname/models/res_partner.py#L262

Added line #L262 was not covered by tests
[("firstname", "=", False), ("lastname", "=", False), ("name", "!=", "")]
)

# Force calculations there
records._inverse_name()
Expand Down
12 changes: 12 additions & 0 deletions partner_firstname/tests/test_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ def tearDown(self):

super(PersonCase, self).tearDown()

def test_module_installation(self):
model = self.env[self.model].with_context(**self.context)
unnamed = model.create(

Check warning on line 38 in partner_firstname/tests/test_create.py

View check run for this annotation

Codecov / codecov/patch

partner_firstname/tests/test_create.py#L37-L38

Added lines #L37 - L38 were not covered by tests
{"name": "", "email": "anon@ymous.org", "type": "invoice"}
)
named = model.create(

Check warning on line 41 in partner_firstname/tests/test_create.py

View check run for this annotation

Codecov / codecov/patch

partner_firstname/tests/test_create.py#L41

Added line #L41 was not covered by tests
{"name": "firstname lastname", "email": "firstname@lastname.org"}
)
model._install_partner_firstname()
self.assertEqual(unnamed.name, "")
self.assertEqual((named.firstname, named.lastname), ("firstname", "lastname"))

Check warning on line 46 in partner_firstname/tests/test_create.py

View check run for this annotation

Codecov / codecov/patch

partner_firstname/tests/test_create.py#L44-L46

Added lines #L44 - L46 were not covered by tests

def test_no_name(self):
"""Name is calculated."""
del self.values["name"]
Expand Down

0 comments on commit 6437657

Please sign in to comment.