Browse Source

Add module partner_contact_birthdate.

pull/714/head
Jairo Llopis 10 years ago
committed by Oihane Crucelaegui
parent
commit
37835447e0
  1. 79
      partner_contact_birthdate/README.rst
  2. 19
      partner_contact_birthdate/__init__.py
  3. 31
      partner_contact_birthdate/__openerp__.py
  4. 19
      partner_contact_birthdate/data/res_partner.yml
  5. 37
      partner_contact_birthdate/i18n/de.po
  6. 38
      partner_contact_birthdate/i18n/es.po
  7. 36
      partner_contact_birthdate/i18n/fr.po
  8. 33
      partner_contact_birthdate/i18n/partner_contact_birthdate.pot
  9. 37
      partner_contact_birthdate/i18n/sl.po
  10. 58
      partner_contact_birthdate/models.py
  11. BIN
      partner_contact_birthdate/static/description/icon.png
  12. 19
      partner_contact_birthdate/tests/__init__.py
  13. 53
      partner_contact_birthdate/tests/test_birthdate.py
  14. 19
      partner_contact_birthdate/views/res_partner.xml

79
partner_contact_birthdate/README.rst

@ -0,0 +1,79 @@
.. 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
------------
* EL Hadji DEM <elhadji.dem@savoirfairelinux.com>
* Jairo Llopis <j.llopis@grupoesoc.es>
* Matjaž Mozetič <m.mozetic@matmoz.si>
* Rudolf Schnapka <schnapkar@golive-saar.de>
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 @@
# -*- coding: 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 @@
# -*- coding: 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": "8.0.1.0.0",
"author": "Odoo Community Association (OCA)",
"category": "Customer Relationship Management",
"website": "https://odoo-community.org/",
"depends": [
"partner_contact_personal_information_page",
],
"data": [
"views/res_partner.xml",
],
}

19
partner_contact_birthdate/data/res_partner.yml

@ -0,0 +1,19 @@
# -*- coding: 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/>.
- !function {model: res.partner, name: _birthdate_install}

37
partner_contact_birthdate/i18n/de.po

@ -0,0 +1,37 @@
# 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: 2015-05-20 07:17+0000\n"
"PO-Revision-Date: 2015-05-20 09:20+0100\n"
"Last-Translator: Rudolf Schnapka <schnapkar@golive-saar.de>\n"
"Language-Team: German <kde-i18n-de@kde.org>\n"
"Language: de\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.7.6\n"
#. module: partner_contact_birthdate
#: field:res.partner,birthdate_date:0
msgid "Birthdate"
msgstr "Geburtsdatum"
#. module: partner_contact_birthdate
#: code:addons/partner_contact_birthdate/models.py:52
#, python-format
msgid ""
"Could not convert '{0.birthdate}' to date in res.partner {0.id} ({0.name}). "
"Skipping."
msgstr ""
#. module: partner_contact_birthdate
#: model:ir.model,name:partner_contact_birthdate.model_res_partner
msgid "Partner"
msgstr "Partner"

38
partner_contact_birthdate/i18n/es.po

@ -0,0 +1,38 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * partner_contact_birthdate
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0-20150514\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-05-20 07:17+0000\n"
"PO-Revision-Date: 2015-05-20 09:21+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_birthdate
#: field:res.partner,birthdate_date:0
msgid "Birthdate"
msgstr "Fecha de nacimiento"
#. module: partner_contact_birthdate
#: code:addons/partner_contact_birthdate/models.py:52
#, python-format
msgid ""
"Could not convert '{0.birthdate}' to date in res.partner {0.id} ({0.name}). "
"Skipping."
msgstr ""
"No se pudo convertir '{0.birthdate}' en fecha en el res.partner {0.id} ({0."
"name}). Omitiéndolo."
#. module: partner_contact_birthdate
#: model:ir.model,name:partner_contact_birthdate.model_res_partner
msgid "Partner"
msgstr "Empresa"

36
partner_contact_birthdate/i18n/fr.po

@ -0,0 +1,36 @@
# 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: 2015-05-20 07:17+0000\n"
"PO-Revision-Date: 2015-05-20 09:20+0100\n"
"Last-Translator: EL Hadji DEM <elhadji.dem@savoirfairelinux.com>\n"
"Language-Team: \n"
"Language: fr\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.7.6\n"
#. module: partner_contact_birthdate
#: field:res.partner,birthdate_date:0
msgid "Birthdate"
msgstr "Date de naissance"
#. module: partner_contact_birthdate
#: code:addons/partner_contact_birthdate/models.py:52
#, python-format
msgid ""
"Could not convert '{0.birthdate}' to date in res.partner {0.id} ({0.name}). "
"Skipping."
msgstr ""
#. module: partner_contact_birthdate
#: model:ir.model,name:partner_contact_birthdate.model_res_partner
msgid "Partner"
msgstr "Partenaire"

33
partner_contact_birthdate/i18n/partner_contact_birthdate.pot

@ -0,0 +1,33 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * partner_contact_birthdate
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0-20150514\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-05-20 07:17+0000\n"
"PO-Revision-Date: 2015-05-20 07:17+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_contact_birthdate
#: field:res.partner,birthdate_date:0
msgid "Birthdate"
msgstr ""
#. module: partner_contact_birthdate
#: code:addons/partner_contact_birthdate/models.py:52
#, python-format
msgid "Could not convert '{0.birthdate}' to date in res.partner {0.id} ({0.name}). Skipping."
msgstr ""
#. module: partner_contact_birthdate
#: model:ir.model,name:partner_contact_birthdate.model_res_partner
msgid "Partner"
msgstr ""

37
partner_contact_birthdate/i18n/sl.po

@ -0,0 +1,37 @@
# 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: 2015-05-20 07:17+0000\n"
"PO-Revision-Date: 2015-05-20 09:22+0100\n"
"Last-Translator: Matjaž Mozetič <m.mozetic@matmoz.si>\n"
"Language-Team: Slovenian <translate@matmoz.si>\n"
"Language: sl\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.7.6\n"
#. module: partner_contact_birthdate
#: field:res.partner,birthdate_date:0
msgid "Birthdate"
msgstr "Rojstni datum"
#. module: partner_contact_birthdate
#: code:addons/partner_contact_birthdate/models.py:52
#, python-format
msgid ""
"Could not convert '{0.birthdate}' to date in res.partner {0.id} ({0.name}). "
"Skipping."
msgstr ""
#. module: partner_contact_birthdate
#: model:ir.model,name:partner_contact_birthdate.model_res_partner
msgid "Partner"
msgstr "Partner"

58
partner_contact_birthdate/models.py

@ -0,0 +1,58 @@
# -*- coding: 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="_birthdate_compute",
inverse="_birthdate_inverse",
store=True)
@api.one
@api.depends("birthdate_date")
def _birthdate_compute(self):
"""Store a string of the new date in the old field."""
self.birthdate = self.birthdate_date
@api.one
def _birthdate_inverse(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 _birthdate_install(self):
"""Export all old birthdates to the new format."""
self.search([('birthdate', "!=", False)])._inverse_birthdate()

BIN
partner_contact_birthdate/static/description/icon.png

After

Width: 128  |  Height: 128  |  Size: 9.2 KiB

19
partner_contact_birthdate/tests/__init__.py

@ -0,0 +1,19 @@
# -*- coding: 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

53
partner_contact_birthdate/tests/test_birthdate.py

@ -0,0 +1,53 @@
# -*- coding: 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 GoodCase(TransactionCase):
def setUp(self):
super(GoodCase, 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(GoodCase, 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)
class BadCase(TransactionCase):
def setUp(self):
super(BadCase, self).setUp()
self.partner = self.env["res.partner"].create({"name": str(self)})
self.birthdate = date.today()
def tearDown(self):
self.assertNotEqual(self.partner.birthdate,
self.partner.birthdate_date)
super(BadCase, self).tearDown()
def test_old_to_new(self):
self.partner.birthdate = "Not a date"

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_personal_information_page.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