From 0e84f689451f808233d55948cdbe1cc67d66380f Mon Sep 17 00:00:00 2001 From: invitu Date: Fri, 11 Nov 2016 16:08:15 -1000 Subject: [PATCH] =?UTF-8?q?[MIG]=20Migration=20partner=5Fcontact=5Fbirthda?= =?UTF-8?q?te=20partner=5Fcontact=5Fgender=20part=E2=80=A6=20(#315)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [MIG] Migration partner_contact_birthdate partner_contact_gender partner_contact_personal_information_page to v10 --- partner_contact_birthdate/__init__.py | 1 + .../{__openerp__.py => __manifest__.py} | 8 ++++-- .../data/res_partner.yml | 5 ---- partner_contact_birthdate/hooks.py | 10 +++++++ .../models/res_partner.py | 9 ++---- .../views/res_partner.xml | 28 +++++++++---------- 6 files changed, 31 insertions(+), 30 deletions(-) rename partner_contact_birthdate/{__openerp__.py => __manifest__.py} (72%) delete mode 100644 partner_contact_birthdate/data/res_partner.yml create mode 100644 partner_contact_birthdate/hooks.py diff --git a/partner_contact_birthdate/__init__.py b/partner_contact_birthdate/__init__.py index 2fe0926df..00ff9b00b 100644 --- a/partner_contact_birthdate/__init__.py +++ b/partner_contact_birthdate/__init__.py @@ -2,3 +2,4 @@ # Copyright (C) 2014-2015 Grupo ESOC # 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/__openerp__.py b/partner_contact_birthdate/__manifest__.py similarity index 72% rename from partner_contact_birthdate/__openerp__.py rename to partner_contact_birthdate/__manifest__.py index fe8b7472c..a8566aa2a 100644 --- a/partner_contact_birthdate/__openerp__.py +++ b/partner_contact_birthdate/__manifest__.py @@ -4,16 +4,18 @@ { "name": "Contact's birthdate", - "version": "9.0.1.0.0", - "author": "Jairo Llopis," + "version": "10.0.1.0.0", + "author": "Tecnativa," "Odoo Community Association (OCA)", "category": "Customer Relationship Management", - "website": "https://odoo-community.org/", + "website": "https://www.tecnativa.com/", "depends": [ "partner_contact_personal_information_page", ], "data": [ "views/res_partner.xml", ], + "post_init_hook": "post_init_hook", + "license": "AGPL-3", 'installable': True, } diff --git a/partner_contact_birthdate/data/res_partner.yml b/partner_contact_birthdate/data/res_partner.yml deleted file mode 100644 index d6be2f47e..000000000 --- a/partner_contact_birthdate/data/res_partner.yml +++ /dev/null @@ -1,5 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (C) 2014-2015 Grupo ESOC -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - -- !function {model: res.partner, name: _birthdate_install} diff --git a/partner_contact_birthdate/hooks.py b/partner_contact_birthdate/hooks.py new file mode 100644 index 000000000..f3d2ca69e --- /dev/null +++ b/partner_contact_birthdate/hooks.py @@ -0,0 +1,10 @@ +# -*- 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/models/res_partner.py b/partner_contact_birthdate/models/res_partner.py index d98771922..829771d11 100644 --- a/partner_contact_birthdate/models/res_partner.py +++ b/partner_contact_birthdate/models/res_partner.py @@ -1,14 +1,14 @@ # -*- 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 _, api, fields, models +from odoo import _, api, fields, models import logging _logger = logging.getLogger(__name__) -class Partner(models.Model): +class ResPartner(models.Model): """Partner with birth date in date format.""" _inherit = "res.partner" @@ -36,8 +36,3 @@ class Partner(models.Model): _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() diff --git a/partner_contact_birthdate/views/res_partner.xml b/partner_contact_birthdate/views/res_partner.xml index 49c636171..4b2d1d1ac 100644 --- a/partner_contact_birthdate/views/res_partner.xml +++ b/partner_contact_birthdate/views/res_partner.xml @@ -1,20 +1,18 @@ - - - - - Birthdate Date field - res.partner - - - - - - - - - + + + Birthdate Date field + res.partner + + + + + + + + +