Browse Source

Add module partner_contact_birthdate.

pull/120/head
Jairo Llopis 9 years ago
parent
commit
4a4568c07b
  1. 76
      partner_contact_birthdate/README.rst
  2. 19
      partner_contact_birthdate/__init__.py
  3. 31
      partner_contact_birthdate/__openerp__.py
  4. 191
      partner_contact_birthdate/i18n/de.po
  5. 23
      partner_contact_birthdate/i18n/es.po
  6. 188
      partner_contact_birthdate/i18n/fr.po
  7. 191
      partner_contact_birthdate/i18n/sl.po
  8. 58
      partner_contact_birthdate/models.py
  9. 19
      partner_contact_birthdate/tests/__init__.py
  10. 38
      partner_contact_birthdate/tests/test_birthdate.py
  11. 19
      partner_contact_birthdate/views/res_partner.xml

76
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 <j.llopis@grupoesoc.es>
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

19
partner_contact_birthdate/__init__.py

@ -0,0 +1,19 @@
# -*- encoding: utf-8 -*-
# Odoo, Open Source Management Solution
# Copyright (C) 2014-2015 Grupo ESOC <www.grupoesoc.es>
#
# 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 <http://www.gnu.org/licenses/>.
from . import models

31
partner_contact_birthdate/__openerp__.py

@ -0,0 +1,31 @@
# -*- encoding: utf-8 -*-
# Odoo, Open Source Management Solution
# Copyright (C) 2014-2015 Grupo ESOC <www.grupoesoc.es>
#
# 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 <http://www.gnu.org/licenses/>.
{
"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",
],
}

191
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 <schnapkar@golive-saar.de>, 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 <schnapkar@golive-saar.de>\n"
"Language-Team: German <kde-i18n-de@kde.org>\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"

23
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 <j.llopis@grupoesoc.es>\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"

188
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 <elhadji.dem@savoirfairelinux.com>\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"

191
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č <m.mozetic@matmoz.si>, 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č <m.mozetic@matmoz.si>\n"
"Language-Team: Slovenian <translate@matmoz.si>\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"

58
partner_contact_birthdate/models.py

@ -0,0 +1,58 @@
# -*- encoding: utf-8 -*-
# Odoo, Open Source Management Solution
# Copyright (C) 2014-2015 Grupo ESOC <www.grupoesoc.es>
#
# 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 <http://www.gnu.org/licenses/>.
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()

19
partner_contact_birthdate/tests/__init__.py

@ -0,0 +1,19 @@
# -*- encoding: utf-8 -*-
# Odoo, Open Source Management Solution
# Copyright (C) 2014-2015 Grupo ESOC <www.grupoesoc.es>
#
# 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 <http://www.gnu.org/licenses/>.
from . import test_birthdate

38
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 <www.grupoesoc.es>
#
# 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 <http://www.gnu.org/licenses/>.
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)

19
partner_contact_birthdate/views/res_partner.xml

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="birthdate_date" model="ir.ui.view">
<field name="name">Birthdate Date field</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="partner_contact_base.personal_information"/>
<field name="arch" type="xml">
<data>
<xpath expr="//group[@name='personal_information_group']">
<field name="birthdate_date"/>
</xpath>
</data>
</field>
</record>
</data>
</openerp>
Loading…
Cancel
Save