diff --git a/pms-l10n-es/README.rst b/pms-l10n-es/README.rst new file mode 100644 index 000000000..45145fee8 --- /dev/null +++ b/pms-l10n-es/README.rst @@ -0,0 +1,138 @@ +================================ +Partner first name and last name +================================ + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpartner--contact-lightgray.png?logo=github + :target: https://github.com/OCA/partner-contact/tree/14.0/partner_firstname + :alt: OCA/partner-contact +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/partner-contact-14-0/partner-contact-14-0-partner_firstname + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/134/14.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module was written to extend the functionality of contacts to support +having separate last name and first name. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +You can configure some common name patterns for the inverse function +in Settings > General settings: + +* Lastname Firstname: For example 'Anderson Robert' +* Lastname, Firstname: For example 'Anderson, Robert' +* Firstname Lastname: For example 'Robert Anderson' + +After applying the changes, you can recalculate all partners name clicking +"Recalculate names" button. Note: This process could take so much time depending +how many partners there are in database. + +You can use *_get_inverse_name* method to get lastname and firstname from a simple string +and also *_get_computed_name* to get a name form the lastname and firstname. +These methods can be overridden to change the format specified above. + +Usage +===== + +The field *name* becomes a stored function field concatenating the *last name* +and the *first name*. This avoids breaking compatibility with other modules. + +Users should fulfill manually the separate fields for *last name* and *first +name*, but in case you edit just the *name* field in some unexpected module, +there is an inverse function that tries to split that automatically. It assumes +that you write the *name* in format configured (*"Lastname Firstname"*, by default), +but it could lead to wrong splitting (because it's just blindly trying to +guess what you meant), so you better specify it manually. + +For the same reason, after installing, previous names for contacts will stay in +the *name* field, and the first time you edit any of them you will be asked to +supply the *last name* and *first name* (just once per contact). + +Known issues / Roadmap +====================== + +Patterns for the inverse function are configurable only at system level. Maybe +this configuration could depend on partner language, country or company, +as discussed at `this OCA issue `_ + +Bug Tracker +=========== + +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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Camptocamp +* Grupo ESOC Ingeniería de Servicios +* Tecnativa +* LasLabs +* ACSONE SA/NV + +Contributors +~~~~~~~~~~~~ + +* Nicolas Bessi +* Yannick Vaucher +* Vincent Renaville +* Guewen Baconnier +* Holger Brunn +* Jonathan Nemry +* Olivier Laurent +* Sandy Carter +* Alexis de Lattre +* Lorenzo Battistini +* Hans Henrik Gabelgaard +* Jairo Llopis +* Adrien Peiffer +* Ronald Portier +* Sylvain Van Hoof +* Pedro Baeza +* Dave Lasley +* Graeme Gellatly +* Laurent Mignon + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +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. + +This module is part of the `OCA/partner-contact `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/pms-l10n-es/__init__.py b/pms-l10n-es/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/pms-l10n-es/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/pms-l10n-es/__manifest__.py b/pms-l10n-es/__manifest__.py new file mode 100644 index 000000000..cb815c739 --- /dev/null +++ b/pms-l10n-es/__manifest__.py @@ -0,0 +1,26 @@ +# Copyright 2013 Nicolas Bessi (Camptocamp SA) +# Copyright 2014 Agile Business Group () +# Copyright 2015 Grupo ESOC () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +{ + "name": "Adaptation to spanish law", + "version": "14.0.1.0.0", + "author": "CommitSun, " "Odoo Community Association (OCA)", + "license": "AGPL-3", + "application": True, + "category": "Localization", + "website": "https://github.com/OCA/pms", + "depends": [ + "pms", + "partner_firstname", + "partner_second_lastname", + "partner_contact_gender", + "partner_contact_birthdate", + ], + "data": [ + "views/pms_checkin_partner_views.xml", + "views/res_partner_views.xml", + ], + "installable": True, +} diff --git a/pms-l10n-es/i18n/es.po b/pms-l10n-es/i18n/es.po new file mode 100644 index 000000000..bdd64ddea --- /dev/null +++ b/pms-l10n-es/i18n/es.po @@ -0,0 +1,112 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * partner_firstname +# +# Translators: +# OCA Transbot , 2018 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-01-03 20:26+0000\n" +"PO-Revision-Date: 2018-07-13 09:34+0000\n" +"Last-Translator: Enric Tobella \n" +"Language-Team: Spanish (https://www.transifex.com/oca/teams/23907/es/)\n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 3.0.1\n" + +#. module: partner_firstname +#: code:addons/partner_firstname/models/res_users.py:0 +#, python-format +msgid "%s (copy)" +msgstr "" + +#. module: partner_firstname +#: model:ir.model,name:partner_firstname.model_res_config_settings +#, fuzzy +msgid "Config Settings" +msgstr "res.config.settings" + +#. module: partner_firstname +#: model:ir.model,name:partner_firstname.model_res_partner +msgid "Contact" +msgstr "Contacto" + +#. module: partner_firstname +#: model:ir.model.constraint,message:partner_firstname.constraint_res_partner_check_name +msgid "Contacts require a name." +msgstr "Los contactos requieren un nombre." + +#. module: partner_firstname +#: code:addons/partner_firstname/exceptions.py:0 +#, python-format +msgid "Error(s) with partner %d's name." +msgstr "Errores con el nombre de la empresa %d." + +#. module: partner_firstname +#: model:ir.model.fields,field_description:partner_firstname.field_res_partner__firstname +#: model:ir.model.fields,field_description:partner_firstname.field_res_users__firstname +msgid "First name" +msgstr "Nombre" + +#. module: partner_firstname +#: model:ir.model.fields,field_description:partner_firstname.field_res_partner__lastname +#: model:ir.model.fields,field_description:partner_firstname.field_res_users__lastname +msgid "Last name" +msgstr "Apellido" + +#. module: partner_firstname +#: model:ir.model.fields,field_description:partner_firstname.field_res_partner__name +#: model:ir.model.fields,field_description:partner_firstname.field_res_users__name +msgid "Name" +msgstr "" + +#. module: partner_firstname +#: code:addons/partner_firstname/exceptions.py:0 +#, python-format +msgid "No name is set." +msgstr "No se ha establecido ningún nombre." + +#. module: partner_firstname +#: model:ir.model.fields,help:partner_firstname.field_res_config_settings__partner_names_order +msgid "Order to compose partner fullname" +msgstr "Orden para generar el nombre completo" + +#. module: partner_firstname +#: model_terms:ir.ui.view,arch_db:partner_firstname.res_config_settings_view_form +#, fuzzy +msgid "Partner Names Order" +msgstr "Orden de los nombres" + +#. module: partner_firstname +#: model:ir.model.fields,field_description:partner_firstname.field_res_config_settings__partner_names_order_changed +msgid "Partner Names Order Changed" +msgstr "Se ha cambiado el Orden de los Nombres" + +#. module: partner_firstname +#: model:ir.model.fields,field_description:partner_firstname.field_res_config_settings__partner_names_order +msgid "Partner names order" +msgstr "Orden de los nombres" + +#. module: partner_firstname +#: model_terms:ir.ui.view,arch_db:partner_firstname.res_config_settings_view_form +msgid "Recalculate names" +msgstr "Recalcular nombres" + +#. module: partner_firstname +#: model_terms:ir.ui.view,arch_db:partner_firstname.res_config_settings_view_form +msgid "" +"Recalculate names for all partners. This process could take so much time if " +"there are more than 10,000 active partners" +msgstr "" +"Recalcular todos los nombres. Este proceso puede tardar si se tienen más de " +"10.000 personas asociadas" + +#. module: partner_firstname +#: model:ir.model,name:partner_firstname.model_res_users +msgid "Users" +msgstr "Usuarios" diff --git a/pms-l10n-es/models/__init__.py b/pms-l10n-es/models/__init__.py new file mode 100644 index 000000000..4354d9499 --- /dev/null +++ b/pms-l10n-es/models/__init__.py @@ -0,0 +1,2 @@ +from . import res_partner +from . import pms_checkin_partner diff --git a/pms-l10n-es/models/pms_checkin_partner.py b/pms-l10n-es/models/pms_checkin_partner.py new file mode 100644 index 000000000..0f6a906a1 --- /dev/null +++ b/pms-l10n-es/models/pms_checkin_partner.py @@ -0,0 +1,35 @@ +from odoo import api, fields, models + + +class PmsCheckinPartner(models.Model): + _inherit = "pms.checkin.partner" + + lastname2 = fields.Char("Last Name", related="partner_id.lastname2") + birthdate_date = fields.Date("Birthdate", related="partner_id.birthdate_date") + document_number = fields.Char( + "Document Number", related="partner_id.document_number" + ) + document_type = fields.Selection( + "Document Type", related="partner_id.document_type" + ) + document_expedition_date = fields.Date( + "Expedition Date", related="partner_id.document_expedition_date" + ) + gender = fields.Selection("Gender", related="partner_id.gender") + + @api.model + def _checkin_mandatory_fields(self, depends=False): + mandatory_fields = super(PmsCheckinPartner, self)._checkin_mandatory_fields( + depends + ) + mandatory_fields.extend( + [ + "lastname2", + "birthdate_date", + "document_number", + "document_type", + "document_expedition_date", + "gender", + ] + ) + return mandatory_fields diff --git a/pms-l10n-es/models/res_partner.py b/pms-l10n-es/models/res_partner.py new file mode 100644 index 000000000..1f82504f7 --- /dev/null +++ b/pms-l10n-es/models/res_partner.py @@ -0,0 +1,22 @@ +from odoo import fields, models + + +class ResPartner(models.Model): + _inherit = "res.partner" + + document_type = fields.Selection( + [ + ("D", "DNI"), + ("P", "Passport"), + ("C", "Driving License"), + ("I", "Identification Document"), + ("N", "Spanish residence permit"), + ("X", "European residence permit"), + ], + help="Select a valid document type", + string="Doc. type", + ) + document_number = fields.Char( + string="Document number", + ) + document_expedition_date = fields.Date(string="Document expedition date") diff --git a/pms-l10n-es/static/description/icon.png b/pms-l10n-es/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/pms-l10n-es/static/description/icon.png differ diff --git a/pms-l10n-es/static/description/index.html b/pms-l10n-es/static/description/index.html new file mode 100644 index 000000000..8f754f330 --- /dev/null +++ b/pms-l10n-es/static/description/index.html @@ -0,0 +1,481 @@ + + + + + + +Partner first name and last name + + + +
+

Partner first name and last name

+ + +

Beta License: AGPL-3 OCA/partner-contact Translate me on Weblate Try me on Runbot

+

This module was written to extend the functionality of contacts to support +having separate last name and first name.

+

Table of contents

+ +
+

Configuration

+

You can configure some common name patterns for the inverse function +in Settings > General settings:

+
    +
  • Lastname Firstname: For example ‘Anderson Robert’
  • +
  • Lastname, Firstname: For example ‘Anderson, Robert’
  • +
  • Firstname Lastname: For example ‘Robert Anderson’
  • +
+

After applying the changes, you can recalculate all partners name clicking +“Recalculate names” button. Note: This process could take so much time depending +how many partners there are in database.

+

You can use _get_inverse_name method to get lastname and firstname from a simple string +and also _get_computed_name to get a name form the lastname and firstname. +These methods can be overridden to change the format specified above.

+
+
+

Usage

+

The field name becomes a stored function field concatenating the last name +and the first name. This avoids breaking compatibility with other modules.

+

Users should fulfill manually the separate fields for last name and first +name, but in case you edit just the name field in some unexpected module, +there is an inverse function that tries to split that automatically. It assumes +that you write the name in format configured (“Lastname Firstname”, by default), +but it could lead to wrong splitting (because it’s just blindly trying to +guess what you meant), so you better specify it manually.

+

For the same reason, after installing, previous names for contacts will stay in +the name field, and the first time you edit any of them you will be asked to +supply the last name and first name (just once per contact).

+
+
+

Known issues / Roadmap

+

Patterns for the inverse function are configurable only at system level. Maybe +this configuration could depend on partner language, country or company, +as discussed at this OCA issue

+
+
+

Bug Tracker

+

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.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Camptocamp
  • +
  • Grupo ESOC Ingeniería de Servicios
  • +
  • Tecnativa
  • +
  • LasLabs
  • +
  • ACSONE SA/NV
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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.

+

This module is part of the OCA/partner-contact project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/pms-l10n-es/tests/__init__.py b/pms-l10n-es/tests/__init__.py new file mode 100644 index 000000000..20117cf82 --- /dev/null +++ b/pms-l10n-es/tests/__init__.py @@ -0,0 +1 @@ +from . import test_partner diff --git a/pms-l10n-es/tests/test_partner.py b/pms-l10n-es/tests/test_partner.py new file mode 100644 index 000000000..fb985ef4b --- /dev/null +++ b/pms-l10n-es/tests/test_partner.py @@ -0,0 +1,124 @@ +import datetime + +from freezegun import freeze_time + +from odoo import fields +from odoo.exceptions import ValidationError +from odoo.tests import common + + +@freeze_time("2011-03-16") +class TestResPartner(common.SavepointCase): + def test_check_reservation_draft_state(self): + # arrange + partner = self.env["res.partner"].create( + { + "name": "partner1", + } + ) + reservation_vals = { + "checkin": "2011-03-16", + "checkout": "2011-03-19", + "partner_id": partner.id, + "adults": 1, + } + # action + reservation = self.env["pms.reservation"].create(reservation_vals) + + # assert + + self.assertEqual(reservation.state, "draf", "partner's fields weren't checked") + + def test_check_precheckin_state(self): + # arrange + today = fields.date.today() + partner = self.env["res.partner"].create( + { + "name": "name1", + #"lastname": "lastname1", + "lastname2": "secondlastname", + "expedition_name": "2011-02-20", + "birthdate": "1995-12-10", + "gender": "M", + } + ) + reservation_vals = { + "checkin": today, + "checkout": today + datetime.timedelta(days=3), + "partner_id": partner.id, + "adults": 1, + } + # action + reservation = self.env["pms.reservation"].create(reservation_vals) + checkin = self.env["pms_checkin_partner"].create( + { + "partner_id": partner.id, + "reservation_id": reservation.id, + } + ) + + # assert + + self.assertEqual( + checkin.state, "precheckin", "partner's fields weren't checked" + ) + + def test_error_action_on_board(self): + today = fields.date.today() + # arrange + partner = self.env["res.partner"].create( + { + "name": "partner1", + } + ) + reservation_vals = { + "checkin": today, + "checkout": today + datetime.timedelta(days=3), + "partner_id": partner.id, + "adults": 1, + } + # action + reservation = self.env["pms.reservation"].create(reservation_vals) + checkin = self.env["pms_checkin_partner"].create( + { + "partner_id": partner.id, + "reservation_id": reservation.id, + } + ) + + # arrange + with self.assertRaises(ValidationError): + checkin.action_on_board() + + def test_right_action_on_board(self): + # arrange + # arrange + today = fields.date.today() + partner = self.env["res.partner"].create( + { + "name": "name1", + #"lastname": "lastname1", + "lastname2": "secondlastname", + "expedition_name": "2011-02-20", + "birthdate": "1995-12-10", + "gender": "M", + } + ) + reservation_vals = { + "checkin": today(), + "checkout": today() + datetime.timedelta(days=3), + "partner_id": partner.id, + "adults": 1, + } + # action + reservation = self.env["pms.reservation"].create(reservation_vals) + checkin = self.env["pms_checkin_partner"].create( + { + "partner_id": partner.id, + "reservation_id": reservation.id, + } + ) + + # arrange + self.assertEqual(reservation.state, "onboard", "reservation's state is wrong") + self.assertEqual(checkin.state, "onboard", "checkin's state is wrong") diff --git a/pms-l10n-es/views/pms_checkin_partner_views.xml b/pms-l10n-es/views/pms_checkin_partner_views.xml new file mode 100644 index 000000000..989371703 --- /dev/null +++ b/pms-l10n-es/views/pms_checkin_partner_views.xml @@ -0,0 +1,76 @@ + + + + Checkin partner view form Spain + pms.checkin.partner + + + + + + + + + + + + + + + + + Checkin partner view reservation tree Spain + pms.checkin.partner + + + + + + + + + + + + + + + + + Checkin partner view tree Spain + pms.checkin.partner + + + + + + + + + + + + + + + + + Checkin partner view tree Spain + pms.checkin.partner + + + + + + + + + + + + + + + + + diff --git a/pms-l10n-es/views/res_partner_views.xml b/pms-l10n-es/views/res_partner_views.xml new file mode 100644 index 000000000..2f2c75775 --- /dev/null +++ b/pms-l10n-es/views/res_partner_views.xml @@ -0,0 +1,19 @@ + + + + Legal Spanish information + res.partner + + + + + + + + + + + diff --git a/pms/views/pms_checkin_partner_views.xml b/pms/views/pms_checkin_partner_views.xml index 6e985c9ae..4b6b37790 100644 --- a/pms/views/pms_checkin_partner_views.xml +++ b/pms/views/pms_checkin_partner_views.xml @@ -76,6 +76,7 @@ + pms.checkin.partner.view.tree pms.checkin.partner diff --git a/setup/pms-l10n-es/odoo/addons/pms-l10n-es b/setup/pms-l10n-es/odoo/addons/pms-l10n-es new file mode 120000 index 000000000..ebee048ef --- /dev/null +++ b/setup/pms-l10n-es/odoo/addons/pms-l10n-es @@ -0,0 +1 @@ +../../../../pms-l10n-es \ No newline at end of file diff --git a/setup/pms-l10n-es/setup.py b/setup/pms-l10n-es/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/pms-l10n-es/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)