Browse Source

partner_firstname: Name is not mandatory if partner is an address

pull/238/head
Sebastien LANGE 9 years ago
committed by Yannick Vaucher
parent
commit
49e71758dc
  1. 3
      partner_firstname/models/partner.py
  2. 14
      partner_firstname/tests/test_empty.py

3
partner_firstname/models/partner.py

@ -146,7 +146,8 @@ class ResPartner(models.Model):
@api.constrains("firstname", "lastname")
def _check_name(self):
"""Ensure at least one name is set."""
if not (self.firstname or self.lastname):
if (self.type == 'contact' or self.company_type == 'company') \
and not (self.firstname or self.lastname):
raise exceptions.EmptyNamesError(self)
@api.one

14
partner_firstname/tests/test_empty.py

@ -42,7 +42,7 @@ class CompanyCase(TransactionCase):
class PersonCase(CompanyCase):
"""Test ``res.partner`` when it is a person."""
context = {"default_is_company": False}
context = {"default_is_company": False, "default_type": 'contact'}
class UserCase(CompanyCase, MailInstalled):
@ -58,3 +58,15 @@ class UserCase(CompanyCase, MailInstalled):
else:
# Run tests
super(UserCase, self).tearDown()
class AddressCase(TransactionCase):
"""Test ``res.partner`` when it is a address."""
def test_new_empty_address(self):
"""Create an empty partner."""
self.original = self.env["res.partner"].create({
"is_company": False,
"type": 'invoice',
"lastname": "",
"firstname": ""})
Loading…
Cancel
Save