From 5179935b8fde1ec9d5a074d2ba7f8cf51fcb4afd Mon Sep 17 00:00:00 2001 From: Jairo Llopis Date: Mon, 7 Sep 2015 13:56:10 +0200 Subject: [PATCH] Fix bug #154. Conflicts: partner_firstname/__openerp__.py partner_firstname/tests/__init__.py Fix flake8 error After all, this was just a workaround. Remove it. The real fix was in #171. I leave the tests. Fix test that was having sentences after return. PEP8 fix. --- partner_firstname/__openerp__.py | 5 ++-- partner_firstname/tests/__init__.py | 9 +++++- partner_firstname/tests/base.py | 3 +- partner_firstname/tests/test_create.py | 5 ++-- partner_firstname/tests/test_delete.py | 38 ++++++++++++++++++++++++++ 5 files changed, 54 insertions(+), 6 deletions(-) create mode 100644 partner_firstname/tests/test_delete.py diff --git a/partner_firstname/__openerp__.py b/partner_firstname/__openerp__.py index 463b01c97..d8c109ae6 100644 --- a/partner_firstname/__openerp__.py +++ b/partner_firstname/__openerp__.py @@ -21,12 +21,13 @@ { 'name': 'Partner first name and last name', 'summary': "Split first name and last name for non company partners", - 'version': '8.0.2.0.1', + 'version': '8.0.2.1.0', 'author': "Camptocamp, Grupo ESOC, Odoo Community Association (OCA)", "license": "AGPL-3", 'maintainer': 'Camptocamp, Acsone', 'category': 'Extra Tools', - 'website': 'http://www.camptocamp.com, http://www.acsone.eu', + 'website': + 'http://www.camptocamp.com, http://www.acsone.eu, http://grupoesoc.es', 'depends': ['base'], 'data': [ 'views/res_partner.xml', diff --git a/partner_firstname/tests/__init__.py b/partner_firstname/tests/__init__.py index 2bdf39b05..69104a4e4 100644 --- a/partner_firstname/tests/__init__.py +++ b/partner_firstname/tests/__init__.py @@ -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 +) diff --git a/partner_firstname/tests/base.py b/partner_firstname/tests/base.py index 68020d3bf..2ca475620 100644 --- a/partner_firstname/tests/base.py +++ b/partner_firstname/tests/base.py @@ -71,7 +71,8 @@ class BaseCase(TransactionCase, MailInstalled): def test_copy(self): """Copy the partner and compare the result.""" self.expect(self.lastname, u"%s (copy)" % self.firstname) - self.changed = self.original.with_context(copy=True, lang="en_US").copy() + self.changed = (self.original.with_context(copy=True, lang="en_US") + .copy()) def test_one_name(self): """Test what happens when only one name is given.""" diff --git a/partner_firstname/tests/test_create.py b/partner_firstname/tests/test_create.py index 6ffe373ac..8f3e06a7f 100644 --- a/partner_firstname/tests/test_create.py +++ b/partner_firstname/tests/test_create.py @@ -62,8 +62,9 @@ class CompanyCase(PersonCase): context = {"default_is_company": True} def setUp(self): - return super(CompanyCase, self).setUp() - self.values.update(lastname=self.values["name"], firstname=False) + super(CompanyCase, self).setUp() + self.good_values.update(lastname=self.values["name"], firstname=False) + self.values = self.good_values.copy() class UserCase(PersonCase, MailInstalled): diff --git a/partner_firstname/tests/test_delete.py b/partner_firstname/tests/test_delete.py new file mode 100644 index 000000000..0729502f1 --- /dev/null +++ b/partner_firstname/tests/test_delete.py @@ -0,0 +1,38 @@ +# -*- 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 + + +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()