From c8d9dbe5f08b3deae3d0f3aab66903d7609a64f7 Mon Sep 17 00:00:00 2001 From: Jairo Llopis Date: Mon, 7 Sep 2015 13:56:10 +0200 Subject: [PATCH 1/4] Fix bug #154. --- partner_firstname/__openerp__.py | 4 +-- partner_firstname/models.py | 3 +- partner_firstname/tests/__init__.py | 2 +- partner_firstname/tests/test_delete.py | 39 ++++++++++++++++++++++++++ 4 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 partner_firstname/tests/test_delete.py diff --git a/partner_firstname/__openerp__.py b/partner_firstname/__openerp__.py index 264b3066e..601aad89c 100644 --- a/partner_firstname/__openerp__.py +++ b/partner_firstname/__openerp__.py @@ -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.0', - 'author': "Camptocamp, 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', diff --git a/partner_firstname/models.py b/partner_firstname/models.py index 48342b20d..fa1f1af75 100644 --- a/partner_firstname/models.py +++ b/partner_firstname/models.py @@ -79,7 +79,8 @@ class ResPartner(models.Model): @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): diff --git a/partner_firstname/tests/__init__.py b/partner_firstname/tests/__init__.py index 239670f65..ddba87365 100644 --- a/partner_firstname/tests/__init__.py +++ b/partner_firstname/tests/__init__.py @@ -28,4 +28,4 @@ # ############################################################################## -from . import test_defaults, test_empty, test_name, test_onchange +from . import test_defaults, test_delete, test_empty, test_name, test_onchange diff --git a/partner_firstname/tests/test_delete.py b/partner_firstname/tests/test_delete.py new file mode 100644 index 000000000..e31a3f44f --- /dev/null +++ b/partner_firstname/tests/test_delete.py @@ -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() From f2ba28e9808fbf61f1a14f29360feb1cbe71492f Mon Sep 17 00:00:00 2001 From: Jairo Llopis Date: Tue, 8 Sep 2015 13:22:14 +0200 Subject: [PATCH 2/4] Fix and test partner_contact_birthdate too. Fix flake8 error too. --- partner_contact_birthdate/models.py | 3 ++- partner_contact_birthdate/tests/__init__.py | 2 +- .../tests/test_delete.py | 27 +++++++++++++++++++ partner_firstname/__openerp__.py | 7 ++--- partner_firstname/tests/test_delete.py | 1 - 5 files changed, 34 insertions(+), 6 deletions(-) create mode 100644 partner_contact_birthdate/tests/test_delete.py diff --git a/partner_contact_birthdate/models.py b/partner_contact_birthdate/models.py index 2686fed6d..f69205d06 100644 --- a/partner_contact_birthdate/models.py +++ b/partner_contact_birthdate/models.py @@ -40,7 +40,8 @@ class Partner(models.Model): @api.depends("birthdate_date") def _birthdate_compute(self): """Store a string of the new date in the old field.""" - self.birthdate = self.birthdate_date + if self.exists(): + self.birthdate = self.birthdate_date @api.one def _birthdate_inverse(self): diff --git a/partner_contact_birthdate/tests/__init__.py b/partner_contact_birthdate/tests/__init__.py index 73d8cb813..b3374a537 100644 --- a/partner_contact_birthdate/tests/__init__.py +++ b/partner_contact_birthdate/tests/__init__.py @@ -16,4 +16,4 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from . import test_birthdate +from . import test_birthdate, test_delete diff --git a/partner_contact_birthdate/tests/test_delete.py b/partner_contact_birthdate/tests/test_delete.py new file mode 100644 index 000000000..d3d4666d8 --- /dev/null +++ b/partner_contact_birthdate/tests/test_delete.py @@ -0,0 +1,27 @@ +# -*- 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 + + +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", "birthdate": "2015-09-28"} + record = self.env[self.model].with_context(**self.context).create(data) + record.unlink() + record.recompute() + + +class PersonCase(CompanyCase): + context = {"default_is_company": False} diff --git a/partner_firstname/__openerp__.py b/partner_firstname/__openerp__.py index 601aad89c..c4df5c3db 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.1.0', - 'author': "Camptocamp,Odoo Community Association (OCA)", + 'version': '8.0.2.1.1', + '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/test_delete.py b/partner_firstname/tests/test_delete.py index e31a3f44f..0729502f1 100644 --- a/partner_firstname/tests/test_delete.py +++ b/partner_firstname/tests/test_delete.py @@ -4,7 +4,6 @@ from openerp.tests.common import TransactionCase from .base import MailInstalled -from .. import exceptions as ex class CompanyCase(TransactionCase): From 0b13c132870618e89b098332bb8d68f74b78f161 Mon Sep 17 00:00:00 2001 From: Jairo Llopis Date: Wed, 9 Sep 2015 10:24:18 +0200 Subject: [PATCH 3/4] After all, this was just a workaround. Remove it. The real fix was in #171. I leave the tests. --- partner_contact_birthdate/models.py | 3 +-- partner_firstname/__openerp__.py | 2 +- partner_firstname/models.py | 3 +-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/partner_contact_birthdate/models.py b/partner_contact_birthdate/models.py index f69205d06..2686fed6d 100644 --- a/partner_contact_birthdate/models.py +++ b/partner_contact_birthdate/models.py @@ -40,8 +40,7 @@ class Partner(models.Model): @api.depends("birthdate_date") def _birthdate_compute(self): """Store a string of the new date in the old field.""" - if self.exists(): - self.birthdate = self.birthdate_date + self.birthdate = self.birthdate_date @api.one def _birthdate_inverse(self): diff --git a/partner_firstname/__openerp__.py b/partner_firstname/__openerp__.py index c4df5c3db..9fb02c998 100644 --- a/partner_firstname/__openerp__.py +++ b/partner_firstname/__openerp__.py @@ -21,7 +21,7 @@ { 'name': 'Partner first name and last name', 'summary': "Split first name and last name for non company partners", - 'version': '8.0.2.1.1', + 'version': '8.0.2.1.0', 'author': "Camptocamp, Grupo ESOC, Odoo Community Association (OCA)", "license": "AGPL-3", 'maintainer': 'Camptocamp, Acsone', diff --git a/partner_firstname/models.py b/partner_firstname/models.py index fa1f1af75..48342b20d 100644 --- a/partner_firstname/models.py +++ b/partner_firstname/models.py @@ -79,8 +79,7 @@ class ResPartner(models.Model): @api.depends("firstname", "lastname") def _compute_name(self): """Write the 'name' field according to splitted data.""" - if self.exists(): - self.name = self._get_computed_name(self.lastname, self.firstname) + self.name = self._get_computed_name(self.lastname, self.firstname) @api.one def _inverse_name_after_cleaning_whitespace(self): From 6457663b3b4b20a5843a0270ff7cb0fb4e6f7bb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Fri, 13 Nov 2015 19:36:29 +0100 Subject: [PATCH 4/4] [UPD] addons table in README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2189b9f95..0617bf2d3 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ addon | version | summary [partner_contact_nationality](partner_contact_nationality/) | 8.0.1.0.0 | Contact's nationality [partner_contact_personal_information_page](partner_contact_personal_information_page/) | 8.0.1.0.0 | Add a page to contacts form to put personal information [partner_external_maps](partner_external_maps/) | 8.0.0.1.0 | Add Map and Map Routing buttons on partner form to open GMaps, OSM, Bing and others -[partner_firstname](partner_firstname/) | 8.0.2.0.0 | Split first name and last name for non company partners +[partner_firstname](partner_firstname/) | 8.0.2.0.1 | Split first name and last name for non company partners [partner_helper](partner_helper/) | 8.0.0.1.0 | Partner Helper [partner_relations](partner_relations/) | 8.0.1.1.0 | Partner relations [partner_second_lastname](partner_second_lastname/) | 8.0.4.0.0 | Partner second last name