diff --git a/partner_contact_birthdate/README.rst b/partner_contact_birthdate/README.rst index d367fd71b..9754a6595 100644 --- a/partner_contact_birthdate/README.rst +++ b/partner_contact_birthdate/README.rst @@ -13,10 +13,6 @@ 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. @@ -33,7 +29,6 @@ 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: @@ -41,13 +36,6 @@ 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 ======= @@ -77,4 +65,3 @@ 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 index c113cb0e9..ece3a2c15 100644 --- a/partner_contact_birthdate/__init__.py +++ b/partner_contact_birthdate/__init__.py @@ -2,4 +2,3 @@ # © 2017-Apertoso N.V. () # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from . import models -from .hooks import post_init_hook diff --git a/partner_contact_birthdate/__manifest__.py b/partner_contact_birthdate/__manifest__.py index 4f9ed0ed1..76c4c8770 100644 --- a/partner_contact_birthdate/__manifest__.py +++ b/partner_contact_birthdate/__manifest__.py @@ -8,14 +8,13 @@ "author": "Tecnativa," "Odoo Community Association (OCA)", "category": "Customer Relationship Management", - "website": "https://www.tecnativa.com/", + "website": "https://github.com/OCA/partner-contact", "depends": [ - "partner_contact_personal_information_page", + "base", ], "data": [ "views/res_partner.xml", ], - "post_init_hook": "post_init_hook", "license": "AGPL-3", 'installable': True, } diff --git a/partner_contact_birthdate/hooks.py b/partner_contact_birthdate/hooks.py deleted file mode 100644 index f3d2ca69e..000000000 --- a/partner_contact_birthdate/hooks.py +++ /dev/null @@ -1,10 +0,0 @@ -# -*- coding: utf-8 -*- - -from odoo import SUPERUSER_ID -from odoo.api import Environment - - -def post_init_hook(cr, pool): - env = Environment(cr, SUPERUSER_ID, {}) - env['res.partner'].search( - [('birthdate', "!=", False)])._birthdate_inverse() diff --git a/partner_contact_birthdate/i18n/fr.po b/partner_contact_birthdate/i18n/fr.po index 34c75c4d8..76a7ca7e6 100644 --- a/partner_contact_birthdate/i18n/fr.po +++ b/partner_contact_birthdate/i18n/fr.po @@ -6,27 +6,24 @@ # OCA Transbot , 2016 msgid "" msgstr "" -"Project-Id-Version: Odoo Server 10.0\n" +"Project-Id-Version: Odoo Server 11.0+e\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-06-10 01:50+0000\n" -"PO-Revision-Date: 2017-06-10 01:50+0000\n" -"Last-Translator: OCA Transbot , 2016\n" -"Language-Team: French (https://www.transifex.com/oca/teams/23907/fr/)\n" +"POT-Creation-Date: 2019-02-11 17:43+0000\n" +"PO-Revision-Date: 2019-02-11 17:43+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" -"Language: fr\n" -"Plural-Forms: nplurals=2; plural=(n > 1);\n" +"Plural-Forms: \n" #. module: partner_contact_birthdate -#: model:ir.model.fields,field_description:partner_contact_birthdate.field_res_partner_birthdate #: model:ir.model.fields,field_description:partner_contact_birthdate.field_res_partner_birthdate_date -#: model:ir.model.fields,field_description:partner_contact_birthdate.field_res_users_birthdate #: model:ir.model.fields,field_description:partner_contact_birthdate.field_res_users_birthdate_date msgid "Birthdate" msgstr "Date de naissance" #. module: partner_contact_birthdate #: model:ir.model,name:partner_contact_birthdate.model_res_partner -msgid "Partner" -msgstr "Partenaire" +msgid "Contact" +msgstr "Contact" diff --git a/partner_contact_birthdate/models/res_partner.py b/partner_contact_birthdate/models/res_partner.py index 053b11d24..0eb0461f4 100644 --- a/partner_contact_birthdate/models/res_partner.py +++ b/partner_contact_birthdate/models/res_partner.py @@ -1,33 +1,11 @@ # Copyright (C) 2014-2015 Grupo ESOC # © 2017-Apertoso N.V. () # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from odoo import api, fields, models -import logging - - -_logger = logging.getLogger(__name__) +from odoo import fields, models class ResPartner(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.""" - self.birthdate_date = self.birthdate diff --git a/partner_contact_birthdate/tests/__init__.py b/partner_contact_birthdate/tests/__init__.py deleted file mode 100644 index 13b6abe56..000000000 --- a/partner_contact_birthdate/tests/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -# Copyright (C) 2014-2015 Grupo ESOC -# © 2017-Apertoso N.V. () -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from . import test_birthdate diff --git a/partner_contact_birthdate/tests/test_birthdate.py b/partner_contact_birthdate/tests/test_birthdate.py deleted file mode 100644 index 7799ad6a0..000000000 --- a/partner_contact_birthdate/tests/test_birthdate.py +++ /dev/null @@ -1,34 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (C) 2014-2015 Grupo ESOC -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - -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)}) - - def test_old_to_new(self): - with self.assertRaises(ValueError): - self.partner.birthdate = "Not a date" diff --git a/partner_contact_birthdate/views/res_partner.xml b/partner_contact_birthdate/views/res_partner.xml index 4b2d1d1ac..b5bf255d9 100644 --- a/partner_contact_birthdate/views/res_partner.xml +++ b/partner_contact_birthdate/views/res_partner.xml @@ -6,13 +6,11 @@ Birthdate Date field res.partner - + - - - - - + + + diff --git a/setup/partner_contact_birthdate/odoo/addons/partner_contact_birthdate b/setup/partner_contact_birthdate/odoo/addons/partner_contact_birthdate new file mode 120000 index 000000000..e9d99692e --- /dev/null +++ b/setup/partner_contact_birthdate/odoo/addons/partner_contact_birthdate @@ -0,0 +1 @@ +../../../../partner_contact_birthdate \ No newline at end of file diff --git a/setup/partner_contact_birthdate/setup.cfg b/setup/partner_contact_birthdate/setup.cfg new file mode 100644 index 000000000..3c6e79cf3 --- /dev/null +++ b/setup/partner_contact_birthdate/setup.cfg @@ -0,0 +1,2 @@ +[bdist_wheel] +universal=1 diff --git a/setup/partner_contact_birthdate/setup.py b/setup/partner_contact_birthdate/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/partner_contact_birthdate/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)