From 4a4568c07b8471090aabc56105d200fc69e79a0b Mon Sep 17 00:00:00 2001 From: Jairo Llopis Date: Tue, 19 May 2015 14:01:42 +0200 Subject: [PATCH] Add module partner_contact_birthdate. --- partner_contact_birthdate/README.rst | 76 +++++++ partner_contact_birthdate/__init__.py | 19 ++ partner_contact_birthdate/__openerp__.py | 31 +++ partner_contact_birthdate/i18n/de.po | 191 ++++++++++++++++++ partner_contact_birthdate/i18n/es.po | 23 +++ partner_contact_birthdate/i18n/fr.po | 188 +++++++++++++++++ partner_contact_birthdate/i18n/sl.po | 191 ++++++++++++++++++ partner_contact_birthdate/models.py | 58 ++++++ partner_contact_birthdate/tests/__init__.py | 19 ++ .../tests/test_birthdate.py | 38 ++++ .../views/res_partner.xml | 19 ++ 11 files changed, 853 insertions(+) create mode 100644 partner_contact_birthdate/README.rst create mode 100644 partner_contact_birthdate/__init__.py create mode 100644 partner_contact_birthdate/__openerp__.py create mode 100644 partner_contact_birthdate/i18n/de.po create mode 100644 partner_contact_birthdate/i18n/es.po create mode 100644 partner_contact_birthdate/i18n/fr.po create mode 100644 partner_contact_birthdate/i18n/sl.po create mode 100644 partner_contact_birthdate/models.py create mode 100644 partner_contact_birthdate/tests/__init__.py create mode 100644 partner_contact_birthdate/tests/test_birthdate.py create mode 100644 partner_contact_birthdate/views/res_partner.xml diff --git a/partner_contact_birthdate/README.rst b/partner_contact_birthdate/README.rst new file mode 100644 index 000000000..d6b6ca6fe --- /dev/null +++ b/partner_contact_birthdate/README.rst @@ -0,0 +1,76 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :alt: License: AGPL-3 + +Module name +=========== + +This module was written to extend the functionality of Odoo to support setting +a birthdate using a date format and allow you to benefit of a clearer API and +UI. + +Installation +============ + +To install this module, you need to: + +* Ensure that the current contents of the *birthdate* field in the + *res.partner* model in your database are empty or in a format easily readable + by the python function strptime_ in case you want this module to + automatically convert those to the new format. +* Install the OCA repository `partner-contact`_. +* Update your modules list. +* Search and install this module. + +Configuration +============= + +No configuration is needed. + +Usage +===== + +To use this module, you need to: + +* Edit or create a partner. +* Ensure it is **not** a company. +* Go to the *Personal Information* sheet. +* Set the birthdate there. + +For further information, please visit: + +* https://www.odoo.com/forum/help-1 +* https://github.com/OCA/partner-contact/ + +Known issues / Roadmap +====================== + +* If you have data in your *res.partner* records' *birthdate* field that cannot + be converted to date by Pyhton's strptime_ function, those records will have + an empty *birthdate_date* after install. + +Credits +======= + +Contributors +------------ + +* Jairo Llopis + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +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. + + +.. _partner-contact: https://github.com/OCA/partner-contact/ +.. _strptime: https://docs.python.org/2/library/datetime.html#datetime.datetime.strptime diff --git a/partner_contact_birthdate/__init__.py b/partner_contact_birthdate/__init__.py new file mode 100644 index 000000000..685080d25 --- /dev/null +++ b/partner_contact_birthdate/__init__.py @@ -0,0 +1,19 @@ +# -*- encoding: utf-8 -*- + +# Odoo, Open Source Management Solution +# Copyright (C) 2014-2015 Grupo ESOC +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +from . import models diff --git a/partner_contact_birthdate/__openerp__.py b/partner_contact_birthdate/__openerp__.py new file mode 100644 index 000000000..eb109fd75 --- /dev/null +++ b/partner_contact_birthdate/__openerp__.py @@ -0,0 +1,31 @@ +# -*- encoding: utf-8 -*- + +# Odoo, Open Source Management Solution +# Copyright (C) 2014-2015 Grupo ESOC +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +{ + "name": "Contact's birthdate", + "version": "1.0", + "author": "Odoo Community Association (OCA)", + "category": "Customer Relationship Management", + "website": "https://odoo-community.org/", + "depends": [ + "base" + ], + "data": [ + "views/res_partner.xml", + ], +} diff --git a/partner_contact_birthdate/i18n/de.po b/partner_contact_birthdate/i18n/de.po new file mode 100644 index 000000000..702587fae --- /dev/null +++ b/partner_contact_birthdate/i18n/de.po @@ -0,0 +1,191 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * base_contact +# +# Rudolf Schnapka , 2014. +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-09-19 22:10+0000\n" +"PO-Revision-Date: 2014-12-30 18:14+0100\n" +"Last-Translator: Rudolf Schnapka \n" +"Language-Team: German \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: \n" +"X-Generator: Lokalize 1.5\n" +"Language: de\n" + +#. module: base_contact +#: view:res.partner:0 +msgid "City" +msgstr "Stadt" + +#. module: base_contact +#: view:res.partner:0 +msgid "other position" +msgstr "andere Position" + +#. module: base_contact +#: view:res.partner:0 +msgid "Contacts" +msgstr "Kontakte" + +#. module: base_contact +#: view:res.partner:0 +msgid "" +"To see personal information about this contact, please go to to the his " +"person form:" +msgstr "" +"Um persönliche Auskunft zu diesem Kontakt zu erhalten, gehen Sie bitte auf " +"die Seite persönlich:" + +#. module: base_contact +#: view:res.partner:0 +msgid "Street..." +msgstr "Straße..." + +#. module: base_contact +#: view:res.partner:0 +msgid "State" +msgstr "Bundesland" + +#. module: base_contact +#: view:res.partner:0 +msgid "at" +msgstr "bei" + +#. module: base_contact +#: view:res.partner:0 +msgid "Tags..." +msgstr "Schlagworte..." + +#. module: base_contact +#: view:res.partner:0 +msgid "Other Positions" +msgstr "Andere Positionen" + +#. module: base_contact +#: view:res.partner:0 +msgid "Phone:" +msgstr "Telefon:" + +#. module: base_contact +#: view:res.partner:0 +msgid "Company" +msgstr "Unternehmen" + +#. module: base_contact +#: field:res.partner,contact_id:0 +msgid "Main Contact" +msgstr "Hauptkontakt" + +#. module: base_contact +#: view:res.partner:0 +msgid "Fax:" +msgstr "Fax:" + +#. module: base_contact +#: code:addons/base_contact/base_contact.py:31 +#, python-format +msgid "Standalone Contact" +msgstr "Alleinstehender Kontakt" + +#. module: base_contact +#: help:res.partner,nationality_id:0 +msgid "Nationality." +msgstr "Nationalität." + +#. module: base_contact +#: view:res.partner:0 +msgid "Address" +msgstr "Anschrift" + +#. module: base_contact +#: field:res.partner,nationality_id:0 +msgid "Nationality" +msgstr "Nationalität" + +#. module: base_contact +#: code:addons/base_contact/base_contact.py:32 +#, python-format +msgid "Attached to existing Contact" +msgstr "Mit bestehendem Kontakt verknüpft" + +#. module: base_contact +#: view:res.partner:0 +msgid "ZIP" +msgstr "PLZ" + +#. module: base_contact +#: view:res.partner:0 +msgid "Country" +msgstr "Land" + +#. module: base_contact +#: field:res.partner,birthdate_date:0 +msgid "Birthdate" +msgstr "Geburtsdatum" + +#. module: base_contact +#: view:res.partner:0 +msgid "Person" +msgstr "Person" + +#. module: base_contact +#: view:res.partner:0 +msgid "Contact" +msgstr "Kontakt" + +#. module: base_contact +#: view:res.partner:0 +msgid "Mobile:" +msgstr "Mobil:" + +#. module: base_contact +#: view:res.partner:0 +msgid "All partner positions" +msgstr "Alle Positionen des Partners" + +#. module: base_contact +#: view:res.partner:0 +msgid "All positions" +msgstr "Alle Positionen" + +#. module: base_contact +#: model:ir.model,name:base_contact.model_ir_actions_act_window +msgid "ir.actions.act_window" +msgstr "" + +#. module: base_contact +#: view:res.partner:0 +msgid "other positions" +msgstr "andere Positionen" + +#. module: base_contact +#: field:res.partner,contact_type:0 +msgid "Contact Type" +msgstr "Kontaktart" + +#. module: base_contact +#: model:ir.model,name:base_contact.model_res_partner +msgid "Partner" +msgstr "Partner" + +#. module: base_contact +#: field:res.partner,other_contact_ids:0 +msgid "Others Positions" +msgstr "Andere Positionen" + +#. module: base_contact +#: view:res.partner:0 +msgid "Personal Information" +msgstr "Persönliche Auskunft" + +#. module: base_contact +#: view:res.partner:0 +msgid "e.g. Sales Director" +msgstr "z. B. Verkaufsleiter" + diff --git a/partner_contact_birthdate/i18n/es.po b/partner_contact_birthdate/i18n/es.po new file mode 100644 index 000000000..b1eadfcbb --- /dev/null +++ b/partner_contact_birthdate/i18n/es.po @@ -0,0 +1,23 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * partner_contact_base +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0-20150514\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-05-19 10:13+0000\n" +"PO-Revision-Date: 2015-05-19 12:16+0100\n" +"Last-Translator: Jairo Llopis \n" +"Language-Team: \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.7.6\n" +"Language: es_ES\n" + +#. module: partner_contact_base +#: view:res.partner:partner_contact_base.personal_information +msgid "Personal Information" +msgstr "Información personal" diff --git a/partner_contact_birthdate/i18n/fr.po b/partner_contact_birthdate/i18n/fr.po new file mode 100644 index 000000000..6348d5b61 --- /dev/null +++ b/partner_contact_birthdate/i18n/fr.po @@ -0,0 +1,188 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * base_contact +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-09-19 22:11+0000\n" +"PO-Revision-Date: 2014-09-19 18:18-0500\n" +"Last-Translator: EL Hadji DEM \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: \n" +"X-Generator: Poedit 1.5.4\n" + +#. module: base_contact +#: view:res.partner:0 +msgid "City" +msgstr "Ville" + +#. module: base_contact +#: view:res.partner:0 +msgid "other position" +msgstr "fonction" + +#. module: base_contact +#: view:res.partner:0 +msgid "Contacts" +msgstr "Contacts" + +#. module: base_contact +#: view:res.partner:0 +msgid "" +"To see personal information about this contact, please go to to the his " +"person form:" +msgstr "" +"Pour voir des informations personnelles sur ce contact, s'il vous plaît " +"aller au formulaire de la personne:" + +#. module: base_contact +#: view:res.partner:0 +msgid "Street..." +msgstr "Rue..." + +#. module: base_contact +#: view:res.partner:0 +msgid "State" +msgstr "État" + +#. module: base_contact +#: view:res.partner:0 +msgid "at" +msgstr "à" + +#. module: base_contact +#: view:res.partner:0 +msgid "Tags..." +msgstr "Étiquettes..." + +#. module: base_contact +#: view:res.partner:0 +msgid "Other Positions" +msgstr "Fonctions" + +#. module: base_contact +#: view:res.partner:0 +msgid "Phone:" +msgstr "Téléphone:" + +#. module: base_contact +#: view:res.partner:0 +msgid "Company" +msgstr "Organisme" + +#. module: base_contact +#: field:res.partner,contact_id:0 +msgid "Main Contact" +msgstr "Principal contact" + +#. module: base_contact +#: view:res.partner:0 +msgid "Fax:" +msgstr "Fax :" + +#. module: base_contact +#: code:addons/base_contact/base_contact.py:31 +#, python-format +msgid "Standalone Contact" +msgstr "Contact autonome" + +#. module: base_contact +#: help:res.partner,nationality_id:0 +msgid "Nationality." +msgstr "Nationalité." + +#. module: base_contact +#: view:res.partner:0 +msgid "Address" +msgstr "Adresse" + +#. module: base_contact +#: field:res.partner,nationality_id:0 +msgid "Nationality" +msgstr "Nationalité" + +#. module: base_contact +#: code:addons/base_contact/base_contact.py:32 +#, python-format +msgid "Attached to existing Contact" +msgstr "Contact rattaché à un contact existant" + +#. module: base_contact +#: view:res.partner:0 +msgid "ZIP" +msgstr "Code postal" + +#. module: base_contact +#: view:res.partner:0 +msgid "Country" +msgstr "Pays" + +#. module: base_contact +#: field:res.partner,birthdate_date:0 +msgid "Birthdate" +msgstr "Date de naissance" + +#. module: base_contact +#: view:res.partner:0 +msgid "Person" +msgstr "Personne" + +#. module: base_contact +#: view:res.partner:0 +msgid "Contact" +msgstr "Contact" + +#. module: base_contact +#: view:res.partner:0 +msgid "Mobile:" +msgstr "Portable :" + +#. module: base_contact +#: view:res.partner:0 +msgid "All partner positions" +msgstr "Tous les contacts" + +#. module: base_contact +#: view:res.partner:0 +msgid "All positions" +msgstr "Tous les contacts" + +#. module: base_contact +#: model:ir.model,name:base_contact.model_ir_actions_act_window +msgid "ir.actions.act_window" +msgstr "ir.actions.act_window" + +#. module: base_contact +#: view:res.partner:0 +msgid "other positions" +msgstr "fonctions" + +#. module: base_contact +#: field:res.partner,contact_type:0 +msgid "Contact Type" +msgstr "Type de contact" + +#. module: base_contact +#: model:ir.model,name:base_contact.model_res_partner +msgid "Partner" +msgstr "Partenaire" + +#. module: base_contact +#: field:res.partner,other_contact_ids:0 +msgid "Others Positions" +msgstr "Fonctions" + +#. module: base_contact +#: view:res.partner:0 +msgid "Personal Information" +msgstr "Informations personnelles" + +#. module: base_contact +#: view:res.partner:0 +msgid "e.g. Sales Director" +msgstr "ex: Directeur des ventes" diff --git a/partner_contact_birthdate/i18n/sl.po b/partner_contact_birthdate/i18n/sl.po new file mode 100644 index 000000000..3e8e6c367 --- /dev/null +++ b/partner_contact_birthdate/i18n/sl.po @@ -0,0 +1,191 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * base_contact +# +# Matjaž Mozetič , 2015. +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-09-19 22:10+0000\n" +"PO-Revision-Date: 2015-03-20 08:34+0100\n" +"Last-Translator: Matjaž Mozetič \n" +"Language-Team: Slovenian \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: \n" +"X-Generator: Lokalize 1.5\n" +"Language: sl\n" + +#. module: base_contact +#: view:res.partner:0 +msgid "City" +msgstr "Kraj" + +#. module: base_contact +#: view:res.partner:0 +msgid "other position" +msgstr "drug položaj" + +#. module: base_contact +#: view:res.partner:0 +msgid "Contacts" +msgstr "Stiki" + +#. module: base_contact +#: view:res.partner:0 +msgid "" +"To see personal information about this contact, please go to to the his " +"person form:" +msgstr "" +"Za ogled osebnih podatkov o tem stiku pojdite na njegov glavni " +"obrazec:" + +#. module: base_contact +#: view:res.partner:0 +msgid "Street..." +msgstr "Ulica..." + +#. module: base_contact +#: view:res.partner:0 +msgid "State" +msgstr "Zvezna država" + +#. module: base_contact +#: view:res.partner:0 +msgid "at" +msgstr "pri" + +#. module: base_contact +#: view:res.partner:0 +msgid "Tags..." +msgstr "Oznake..." + +#. module: base_contact +#: view:res.partner:0 +msgid "Other Positions" +msgstr "Drugi položaji" + +#. module: base_contact +#: view:res.partner:0 +msgid "Phone:" +msgstr "Telefon:" + +#. module: base_contact +#: view:res.partner:0 +msgid "Company" +msgstr "Družba" + +#. module: base_contact +#: field:res.partner,contact_id:0 +msgid "Main Contact" +msgstr "Glavni stik" + +#. module: base_contact +#: view:res.partner:0 +msgid "Fax:" +msgstr "Faks:" + +#. module: base_contact +#: code:addons/base_contact/base_contact.py:31 +#, python-format +msgid "Standalone Contact" +msgstr "Samostojni stik" + +#. module: base_contact +#: help:res.partner,nationality_id:0 +msgid "Nationality." +msgstr "Nacionalnost" + +#. module: base_contact +#: view:res.partner:0 +msgid "Address" +msgstr "Naslov" + +#. module: base_contact +#: field:res.partner,nationality_id:0 +msgid "Nationality" +msgstr "Nacionalnost" + +#. module: base_contact +#: code:addons/base_contact/base_contact.py:32 +#, python-format +msgid "Attached to existing Contact" +msgstr "Pripeto obstoječemu stiku" + +#. module: base_contact +#: view:res.partner:0 +msgid "ZIP" +msgstr "Poštna številka" + +#. module: base_contact +#: view:res.partner:0 +msgid "Country" +msgstr "Država" + +#. module: base_contact +#: field:res.partner,birthdate_date:0 +msgid "Birthdate" +msgstr "Rojstni datum" + +#. module: base_contact +#: view:res.partner:0 +msgid "Person" +msgstr "Oseba" + +#. module: base_contact +#: view:res.partner:0 +msgid "Contact" +msgstr "Stik" + +#. module: base_contact +#: view:res.partner:0 +msgid "Mobile:" +msgstr "Mobilni telefon:" + +#. module: base_contact +#: view:res.partner:0 +msgid "All partner positions" +msgstr "Vsi partnerjevi položaji" + +#. module: base_contact +#: view:res.partner:0 +msgid "All positions" +msgstr "Vsi položaji" + +#. module: base_contact +#: model:ir.model,name:base_contact.model_ir_actions_act_window +msgid "ir.actions.act_window" +msgstr "ir.actions.act_window" + +#. module: base_contact +#: view:res.partner:0 +msgid "other positions" +msgstr "drugi položaji" + +#. module: base_contact +#: field:res.partner,contact_type:0 +msgid "Contact Type" +msgstr "Tip stika" + +#. module: base_contact +#: model:ir.model,name:base_contact.model_res_partner +msgid "Partner" +msgstr "Partner" + +#. module: base_contact +#: field:res.partner,other_contact_ids:0 +msgid "Others Positions" +msgstr "Drugi položaji" + +#. module: base_contact +#: view:res.partner:0 +msgid "Personal Information" +msgstr "Osebni podatki" + +#. module: base_contact +#: view:res.partner:0 +msgid "e.g. Sales Director" +msgstr "npr. vodja prodaje" + diff --git a/partner_contact_birthdate/models.py b/partner_contact_birthdate/models.py new file mode 100644 index 000000000..84fbf7e99 --- /dev/null +++ b/partner_contact_birthdate/models.py @@ -0,0 +1,58 @@ +# -*- encoding: utf-8 -*- + +# Odoo, Open Source Management Solution +# Copyright (C) 2014-2015 Grupo ESOC +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +from openerp import api, fields, models +import logging + + +_logger = logging.getLogger(__name__) + + +class Partner(models.Model): + """Partner with birth date in date format.""" + _inherit = "res.partner" + + # New birthdate field in date format + birthdate_date = fields.Date("Birthdate") + + # Make the old Char field to reflect the new Date field + birthdate = fields.Char( + compute="_compute_birthdate", + inverse="_inverse_birthdate", + store=True) + + @api.one + @api.depends("birthdate_date") + def _compute_birthdate(self): + """Store a string of the new date in the old field.""" + self.birthdate = self.birthdate_date + + @api.one + def _inverse_birthdate(self): + """Convert the old Char date to the new Date format.""" + try: + self.birthdate_date = self.birthdate + except ValueError: + _logger.warn( + _("Could not convert '{0.birthdate}' to date in " + "res.partner {0.id} ({0.name}). Skipping.").format(self)) + + @api.model + def _install_birthdate_date(self): + """Export all old birthdates to the new format.""" + self.search([('birthdate', "!=", False)])._inverse_birthdate() diff --git a/partner_contact_birthdate/tests/__init__.py b/partner_contact_birthdate/tests/__init__.py new file mode 100644 index 000000000..67301d8d7 --- /dev/null +++ b/partner_contact_birthdate/tests/__init__.py @@ -0,0 +1,19 @@ +# -*- encoding: utf-8 -*- + +# Odoo, Open Source Management Solution +# Copyright (C) 2014-2015 Grupo ESOC +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +from . import test_birthdate diff --git a/partner_contact_birthdate/tests/test_birthdate.py b/partner_contact_birthdate/tests/test_birthdate.py new file mode 100644 index 000000000..57600f43d --- /dev/null +++ b/partner_contact_birthdate/tests/test_birthdate.py @@ -0,0 +1,38 @@ +# -*- encoding: utf-8 -*- + +# Odoo, Open Source Management Solution +# Copyright (C) 2014-2015 Grupo ESOC +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +from openerp import fields +from openerp.tests.common import TransactionCase +from datetime import date + + +class BirthdateCase(TransactionCase): + def setUp(self): + super(BirthdateCase, self).setUp() + self.partner = self.env["res.partner"].create({"name": str(self)}) + self.birthdate = date.today() + + def tearDown(self): + self.assertEqual(self.partner.birthdate, self.partner.birthdate_date) + super(BirthdateCase, self).tearDown() + + def test_new_to_old(self): + self.partner.birthdate_date = self.birthdate + + def test_old_to_new(self): + self.partner.birthdate = fields.Date.to_string(self.birthdate) diff --git a/partner_contact_birthdate/views/res_partner.xml b/partner_contact_birthdate/views/res_partner.xml new file mode 100644 index 000000000..008d50560 --- /dev/null +++ b/partner_contact_birthdate/views/res_partner.xml @@ -0,0 +1,19 @@ + + + + + + Birthdate Date field + res.partner + + + + + + + + + + + +