From f2ba28e9808fbf61f1a14f29360feb1cbe71492f Mon Sep 17 00:00:00 2001 From: Jairo Llopis Date: Tue, 8 Sep 2015 13:22:14 +0200 Subject: [PATCH] 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):