diff --git a/partner_second_lastname/README.rst b/partner_second_lastname/README.rst index 11c1229f7..0b7187ac0 100644 --- a/partner_second_lastname/README.rst +++ b/partner_second_lastname/README.rst @@ -11,7 +11,7 @@ support having a second lastname for contact partners. In some countries, it's important to have a second last name for contacts. -Contact partners will need to fulfill at least one of the name fields +Contact partners will need to fill at least one of the name fields (*First name*, *First last name* or *Second last name*). Configuration @@ -53,7 +53,7 @@ you easily in some corner cases. .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/134/8.0 + :target: https://runbot.odoo-community.org/runbot/134/10.0 Known issues / Roadmap @@ -71,7 +71,7 @@ Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed feedback `here -`_. +`_. Credits @@ -80,10 +80,9 @@ Credits Contributors ------------ -* `Grupo ESOC `_: - * `Jairo Llopis `_. -* `Antiun Ingeniería S.L. `_: - * `Antonio Espinosa `_. +* Jairo Llopis . +* Antonio Espinosa. +* Pedro M. Baeza . Maintainer ---------- @@ -98,4 +97,4 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -To contribute to this module, please visit http://odoo-community.org. +To contribute to this module, please visit https://odoo-community.org. diff --git a/partner_second_lastname/__openerp__.py b/partner_second_lastname/__manifest__.py similarity index 53% rename from partner_second_lastname/__openerp__.py rename to partner_second_lastname/__manifest__.py index 4acde00b1..3027132f3 100644 --- a/partner_second_lastname/__openerp__.py +++ b/partner_second_lastname/__manifest__.py @@ -1,24 +1,24 @@ # -*- coding: utf-8 -*- +# Copyright 2015 Grupo ESOC Ingeniería de Servicios, S.L.U. - Jairo Llopis +# Copyright 2015 Antiun Ingenieria S.L. - Antonio Espinosa +# Copyright 2017 Tecnativa - Pedro M. Baeza # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -# © 2015 Grupo ESOC Ingeniería de Servicios, S.L.U. { "name": "Partner second last name", "summary": "Have split first and second lastnames", - "version": "8.0.4.1.0", + "version": "10.0.1.0.0", "license": "AGPL-3", - "website": "https://grupoesoc.es", - "author": "Grupo ESOC Ingeniería de Servicios, " + "website": "https://www.tecnativa.com", + "author": "Tecnativa, " "Odoo Community Association (OCA)", - "maintainer": "Odoo Community Association (OCA)", - "category": "Extra Tools", + "category": "Partner Management", "depends": [ - "partner_firstname" + "partner_firstname", ], "data": [ "views/res_partner.xml", "views/res_user.xml", ], "installable": True, - 'images': [], } diff --git a/partner_second_lastname/i18n/es.po b/partner_second_lastname/i18n/es.po index 11ee505fa..7360bbd61 100644 --- a/partner_second_lastname/i18n/es.po +++ b/partner_second_lastname/i18n/es.po @@ -1,21 +1,19 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: -# * partner_lastname2 +# * partner_second_lastname # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 8.0-20150327\n" +"Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-08-13 11:16+0100\n" -"PO-Revision-Date: 2015-08-13 11:16+0100\n" -"Last-Translator: Jairo Llopis \n" +"POT-Creation-Date: 2017-06-22 00:28+0000\n" +"PO-Revision-Date: 2017-06-22 00:28+0000\n" +"Last-Translator: <>\n" "Language-Team: \n" -"Language: es_ES\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" -"X-Generator: Poedit 1.8.1\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" #. module: partner_second_lastname #: model:ir.model,name:partner_second_lastname.model_res_partner @@ -23,46 +21,12 @@ msgid "Partner" msgstr "Empresa" #. module: partner_second_lastname -#: field:res.partner,lastname2:0 +#: model:ir.model.fields,field_description:partner_second_lastname.field_res_partner_lastname2 msgid "Second last name" msgstr "Segundo apellido" #. module: partner_second_lastname -#: view:res.partner:partner_second_lastname.partner_form -#: view:res.partner:partner_second_lastname.partner_simple_form -msgid "" -"{\n" -" 'required': [('firstname', '=', False),\n" -" ('lastname2', '=', False),\n" -" ('is_company', '=', False)]\n" -" }" -msgstr "" +#: model:ir.model,name:partner_second_lastname.model_base_config_settings +msgid "base.config.settings" +msgstr "base.config.settings" -#. module: partner_second_lastname -#: view:res.users:partner_second_lastname.users_form -msgid "" -"{\n" -" 'required': [('firstname', '=', False),\n" -" ('lastname2', '=', False)]\n" -" }" -msgstr "" - -#. module: partner_second_lastname -#: view:res.partner:partner_second_lastname.partner_form -#: view:res.partner:partner_second_lastname.partner_simple_form -msgid "" -"{\n" -" 'required': [('lastname', '=', False),\n" -" ('lastname2', '=', False),\n" -" ('is_company', '=', False)]\n" -" }" -msgstr "" - -#. module: partner_second_lastname -#: view:res.users:partner_second_lastname.users_form -msgid "" -"{\n" -" 'required': [('lastname', '=', False),\n" -" ('lastname2', '=', False)]\n" -" }" -msgstr "" diff --git a/partner_second_lastname/i18n/partner_second_lastname.pot b/partner_second_lastname/i18n/partner_second_lastname.pot deleted file mode 100644 index fdf7d1005..000000000 --- a/partner_second_lastname/i18n/partner_second_lastname.pot +++ /dev/null @@ -1,63 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * partner_second_lastname -# -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 8.0-20150811\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-08-13 09:15+0000\n" -"PO-Revision-Date: 2015-08-13 09:15+0000\n" -"Last-Translator: <>\n" -"Language-Team: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: \n" -"Plural-Forms: \n" - -#. module: partner_second_lastname -#: model:ir.model,name:partner_second_lastname.model_res_partner -msgid "Partner" -msgstr "" - -#. module: partner_second_lastname -#: field:res.partner,lastname2:0 -msgid "Second last name" -msgstr "" - -#. module: partner_second_lastname -#: view:res.partner:partner_second_lastname.partner_form -#: view:res.partner:partner_second_lastname.partner_simple_form -msgid "{\n" -" 'required': [('firstname', '=', False),\n" -" ('lastname2', '=', False),\n" -" ('is_company', '=', False)]\n" -" }" -msgstr "" - -#. module: partner_second_lastname -#: view:res.users:partner_second_lastname.users_form -msgid "{\n" -" 'required': [('firstname', '=', False),\n" -" ('lastname2', '=', False)]\n" -" }" -msgstr "" - -#. module: partner_second_lastname -#: view:res.partner:partner_second_lastname.partner_form -#: view:res.partner:partner_second_lastname.partner_simple_form -msgid "{\n" -" 'required': [('lastname', '=', False),\n" -" ('lastname2', '=', False),\n" -" ('is_company', '=', False)]\n" -" }" -msgstr "" - -#. module: partner_second_lastname -#: view:res.users:partner_second_lastname.users_form -msgid "{\n" -" 'required': [('lastname', '=', False),\n" -" ('lastname2', '=', False)]\n" -" }" -msgstr "" - diff --git a/partner_second_lastname/models/base_config_settings.py b/partner_second_lastname/models/base_config_settings.py index f11d8ca57..094214a22 100644 --- a/partner_second_lastname/models/base_config_settings.py +++ b/partner_second_lastname/models/base_config_settings.py @@ -2,7 +2,7 @@ # © 2015 Antiun Ingenieria S.L. - Antonio Espinosa # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from openerp import models, api +from odoo import models, api class BaseConfigSettings(models.TransientModel): diff --git a/partner_second_lastname/models/res_partner.py b/partner_second_lastname/models/res_partner.py index 8d4640dfa..e006c00b6 100644 --- a/partner_second_lastname/models/res_partner.py +++ b/partner_second_lastname/models/res_partner.py @@ -1,15 +1,15 @@ # -*- coding: utf-8 -*- # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -# © 2015 Grupo ESOC Ingeniería de Servicios, S.L.U. -# © 2015 Antiun Ingenieria S.L. - Antonio Espinosa +# Copyright 2015 Grupo ESOC Ingeniería de Servicios, S.L.U. - Jairo Llopis +# Copyright 2015 Antiun Ingenieria S.L. - Antonio Espinosa +# Copyright 2017 Tecnativa - Pedro M. Baeza -from openerp import api, fields, models -from openerp.addons.partner_firstname.models import exceptions +from odoo import api, fields, models +from odoo.addons.partner_firstname import exceptions class ResPartner(models.Model): """Adds a second last name.""" - _inherit = "res.partner" lastname2 = fields.Char("Second last name", oldname="lastname_second") @@ -41,20 +41,20 @@ class ResPartner(models.Model): names.append(firstname) return u" ".join(names) - @api.one @api.depends("firstname", "lastname", "lastname2") def _compute_name(self): """Write :attr:`~.name` according to splitted data.""" - self.name = self._get_computed_name( - self.lastname, self.firstname, self.lastname2) + for partner in self: + partner.name = self._get_computed_name( + partner.lastname, partner.firstname, partner.lastname2, + ) @api.one def _inverse_name(self): """Try to revert the effect of :meth:`._compute_name`.""" parts = self._get_inverse_name(self.name, self.is_company) - # Avoid to hit :meth:`~._check_name` with all 3 fields being ``False`` - before, after = dict(), dict() + before, after = {}, {} for key, value in parts.iteritems(): (before if value else after)[key] = value if any([before[k] != self[k] for k in before.keys()]): @@ -96,17 +96,16 @@ class ResPartner(models.Model): result['lastname2'] = parts[1] return result - @api.one @api.constrains("firstname", "lastname", "lastname2") def _check_name(self): """Ensure at least one name is set.""" try: super(ResPartner, self)._check_name() - except exceptions.EmptyNamesError as error: - if not self.lastname2: - raise error + except exceptions.EmptyNamesError: + for partner in self: + if not partner.lastname2: + raise - @api.one @api.onchange("firstname", "lastname", "lastname2") def _onchange_subnames(self): """Trigger onchange with :attr:`~.lastname2` too.""" diff --git a/partner_second_lastname/tests/__init__.py b/partner_second_lastname/tests/__init__.py index 36f666cf3..9a38fb683 100644 --- a/partner_second_lastname/tests/__init__.py +++ b/partner_second_lastname/tests/__init__.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -# © 2015 Grupo ESOC Ingeniería de Servicios, S.L.U. -from . import test_name, test_onchange -from openerp.addons.partner_firstname.tests import test_empty +from . import test_name +from . import test_onchange +from . import test_config +from odoo.addons.partner_firstname.tests import test_empty diff --git a/partner_second_lastname/tests/test_config.py b/partner_second_lastname/tests/test_config.py new file mode 100644 index 000000000..9a14d116f --- /dev/null +++ b/partner_second_lastname/tests/test_config.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 Tecnativa - Pedro M. Baeza +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo.tests import common + + +class TestConfig(common.SavepointCase): + @classmethod + def setUpClass(cls): + super(TestConfig, cls).setUpClass() + cls.wizard = cls.env['base.config.settings'].create({}) + cls.partner = cls.env['res.partner'].create({ + 'firstname': "First", + 'lastname': "Last", + 'lastname2': "Second", + }) + + def test_last_first(self): + self.wizard.partner_names_order = 'last_first' + self.wizard.set_partner_names_order() + self.wizard.action_recalculate_partners_name() + self.assertEqual(self.partner.name, "Last Second First") + + def test_last_first_comma(self): + self.wizard.partner_names_order = 'last_first_comma' + self.wizard.set_partner_names_order() + self.wizard.action_recalculate_partners_name() + self.assertEqual(self.partner.name, "Last Second, First") + + def test_first_last(self): + self.wizard.partner_names_order = 'first_last' + self.wizard.set_partner_names_order() + self.wizard.action_recalculate_partners_name() + self.assertEqual(self.partner.name, "First Last Second") diff --git a/partner_second_lastname/tests/test_name.py b/partner_second_lastname/tests/test_name.py index 92c963668..5d9e2834f 100644 --- a/partner_second_lastname/tests/test_name.py +++ b/partner_second_lastname/tests/test_name.py @@ -3,8 +3,8 @@ # © 2015 Grupo ESOC Ingeniería de Servicios, S.L.U. # © 2015 Antiun Ingenieria S.L. - Antonio Espinosa -from openerp.tests.common import TransactionCase -from openerp.addons.partner_firstname.tests.base import MailInstalled +from odoo.tests.common import TransactionCase +from odoo.addons.partner_firstname.tests.base import MailInstalled class CompanyCase(TransactionCase): diff --git a/partner_second_lastname/tests/test_onchange.py b/partner_second_lastname/tests/test_onchange.py index 4d6ae367c..1c26b8d78 100644 --- a/partner_second_lastname/tests/test_onchange.py +++ b/partner_second_lastname/tests/test_onchange.py @@ -8,7 +8,7 @@ The form operates in onchange mode, with its limitations. """ -from openerp.tests.common import TransactionCase +from odoo.tests.common import TransactionCase class OnChangeCase(TransactionCase): @@ -31,6 +31,7 @@ class PartnerCompanyCase(OnChangeCase): def tearDown(self): """Companies never have ``firstname`` nor ``lastname2``.""" + super(PartnerCompanyCase, self).tearDown() self.assertEqual(self.partner.firstname, False) self.assertEqual(self.partner.lastname2, False) diff --git a/partner_second_lastname/views/res_partner.xml b/partner_second_lastname/views/res_partner.xml index 94a710ce1..5b9cc554d 100644 --- a/partner_second_lastname/views/res_partner.xml +++ b/partner_second_lastname/views/res_partner.xml @@ -1,105 +1,54 @@ - - - - - - Add second last name - res.partner - - - - - { - 'required': [('lastname', '=', False), - ('lastname2', '=', False), - ('is_company', '=', False)] - } - - - - { - 'required': [('firstname', '=', False), - ('lastname2', '=', False), - ('is_company', '=', False)] - } - - - - - - - - - - - Add second last name - res.partner - - - - - - { - 'required': [('lastname', '=', False), - ('lastname2', '=', False), - ('is_company', '=', False)] - } - - - - { - 'required': [('firstname', '=', False), - ('lastname2', '=', False), - ('is_company', '=', False)] - } - - - - - - - - - { - 'required': [('lastname', '=', False), - ('lastname2', '=', False), - ('is_company', '=', False)] - } - - - - { - 'required': [('firstname', '=', False), - ('lastname2', '=', False), - ('is_company', '=', False)] - } - - - - - - - - - - - + + + + res.partner + + + + + {'required': [('lastname', '=', False), ('lastname2', '=', False), ('is_company', '=', False)]} + + + {'required': [('firstname', '=', False), ('lastname2', '=', False), ('is_company', '=', False)]} + + + + + + + + + + res.partner + + + + + + {'required': [('lastname', '=', False), ('lastname2', '=', False), ('is_company', '=', False)]} + + + + {'required': [('firstname', '=', False), ('lastname2', '=', False), ('is_company', '=', False)]} + + + + + + + {'required': [('lastname', '=', False), ('lastname2', '=', False), ('is_company', '=', False)]} + + + {'required': [('firstname', '=', False), ('lastname2', '=', False), ('is_company', '=', False)]} + + + + + + + + + diff --git a/partner_second_lastname/views/res_user.xml b/partner_second_lastname/views/res_user.xml index 76ae48121..f477bf334 100644 --- a/partner_second_lastname/views/res_user.xml +++ b/partner_second_lastname/views/res_user.xml @@ -1,42 +1,30 @@ - + + - - + + Add second last name + res.users + + + + + {'required': [('lastname', '=', False), ('lastname2', '=', False)]} + - - + + {'required': [('firstname', '=', False), ('lastname2', '=', False)]} + - - Add second last name - res.users - - - - - { - 'required': [('lastname', '=', False), - ('lastname2', '=', False)] - } - + + + + + + - - { - 'required': [('firstname', '=', False), - ('lastname2', '=', False)] - } - - - - - - - - - - - +