Skip to content

Commit

Permalink
Fix bug OCA#154.
Browse files Browse the repository at this point in the history
Conflicts:
	partner_firstname/__openerp__.py
	partner_firstname/tests/__init__.py
  • Loading branch information
Jairo Llopis authored and yvaucher committed Jan 18, 2016
1 parent 6b194f3 commit e7fe070
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 4 deletions.
4 changes: 2 additions & 2 deletions partner_firstname/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
{
'name': 'Partner first name and last name',
'summary': "Split first name and last name for non company partners",
'version': '8.0.2.0.1',
'author': "Camptocamp, Grupo ESOC, Odoo Community Association (OCA)",
'version': '8.0.2.1.0',
'author': "Camptocamp,Odoo Community Association (OCA)",
"license": "AGPL-3",
'maintainer': 'Camptocamp, Acsone',
'category': 'Extra Tools',
Expand Down
3 changes: 2 additions & 1 deletion partner_firstname/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ def _get_computed_name(self, lastname, firstname):
@api.depends("firstname", "lastname")
def _compute_name(self):
"""Write the 'name' field according to splitted data."""
self.name = self._get_computed_name(self.lastname, self.firstname)
if self.exists():
self.name = self._get_computed_name(self.lastname, self.firstname)

@api.one
def _inverse_name_after_cleaning_whitespace(self):
Expand Down
9 changes: 8 additions & 1 deletion partner_firstname/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,11 @@
#
##############################################################################

from . import test_create, test_defaults, test_empty, test_name, test_onchange
from . import (
test_create,
test_defaults,
test_delete,
test_empty,
test_name,
test_onchange
)
39 changes: 39 additions & 0 deletions partner_firstname/tests/test_delete.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# -*- coding: utf-8 -*-
# © 2015 Grupo ESOC
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openerp.tests.common import TransactionCase
from .base import MailInstalled
from .. import exceptions as ex


class CompanyCase(TransactionCase):
model = "res.partner"
context = {"default_is_company": True}

def test_computing_after_unlink(self):
"""Test what happens if recomputed after unlinking.
This test might seem useless, but really this happens when module
``partner_relations`` is installed.
See https://github.com/OCA/partner-contact/issues/154.
"""
data = {"name": u"Söme name"}
record = self.env[self.model].with_context(**self.context).create(data)
record.unlink()
record.recompute()


class PersonCase(CompanyCase):
context = {"default_is_company": False}


class UserCase(CompanyCase, MailInstalled):
model = "res.users"
context = {"default_login": "user@example.com"}

def test_computing_after_unlink(self):
# Cannot create users if ``mail`` is installed
if not self.mail_installed():
super(UserCase, self).test_computing_after_unlink()

0 comments on commit e7fe070

Please sign in to comment.