-
-
Notifications
You must be signed in to change notification settings - Fork 862
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[16.0][FIX] partner_firstname: fix installation w/ missing names #1678
base: 16.0
Are you sure you want to change the base?
Conversation
@mohs8421 could you please add a test for this change?
Thanks! |
I tried to write a test for it, but it is not possible with the module in place to test this, as the module itself prevents that. For reference, here is the testcode: def test_module_installation(self):
model = self.env[self.model].with_context(**self.context)
unnamed = model.create({'name': '', 'email': '[email protected]'})
named = model.create({'name': 'firstname lastname', 'email': '[email protected]'})
model._install_partner_firstname()
self.assertEqual(unnamed.name, '')
self.assertEqual((named.firstname, named.lastname), ('firstname', 'lastname')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, seems safer that way.
You could with mock.patch.object(ResPartner, "_update_next_invoice_date") as mock_update:
... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mohs8421 I think your test is nearly working. I've added your test to the test_empty.py file and just added the contact "type": "invoice" because empty name is not allowed on all contact types. Than the tests run successfully.
class AddressCase(TransactionCase):
...
def test_module_installation(self):
"""Create an invoice patner without name."""
model = self.env["res.partner"]
unnamed = model.create({'name': '', 'email': '[email protected]', "type": "invoice"})
named = model.create({'name': 'firstname lastname', 'email': '[email protected]'})
model._install_partner_firstname()
self.assertEqual(unnamed.name, '')
self.assertEqual((named.firstname, named.lastname), ('firstname', 'lastname'))
If you add your tests, and squash all commits, I will also approve this PR.
Resolve issue blocking partner_firstname from installation This change fixes this bug: OCA#1677 With that the module can be installed as only partners with names will be processed
This change fixes this bug: #1677
With that the module can be installed as only partners with names will be processed