diff --git a/partner_firstname/models/res_partner.py b/partner_firstname/models/res_partner.py index 18438a4d36f..7a36cccdd01 100644 --- a/partner_firstname/models/res_partner.py +++ b/partner_firstname/models/res_partner.py @@ -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( + [("firstname", "=", False), ("lastname", "=", False), ("name", "!=", "")] + ) # Force calculations there records._inverse_name() diff --git a/partner_firstname/tests/test_create.py b/partner_firstname/tests/test_create.py index 5baf777e0a9..26f294d6d61 100644 --- a/partner_firstname/tests/test_create.py +++ b/partner_firstname/tests/test_create.py @@ -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( + {"name": "", "email": "anon@ymous.org", "type": "invoice"} + ) + named = model.create( + {"name": "firstname lastname", "email": "firstname@lastname.org"} + ) + model._install_partner_firstname() + self.assertEqual(unnamed.name, "") + self.assertEqual((named.firstname, named.lastname), ("firstname", "lastname")) + def test_no_name(self): """Name is calculated.""" del self.values["name"]