From 98f43f8e42c4f592ea1dc2ed2f8ef936c83dadfd Mon Sep 17 00:00:00 2001 From: houssine Date: Fri, 10 May 2019 18:30:56 +0200 Subject: [PATCH] [MIG] migrate to v12 --- partner_age/__manifest__.py | 22 ++++++++++++++++++++ partner_age/__openerp__.py | 37 ---------------------------------- partner_age/models/__init__.py | 2 +- partner_age/models/partner.py | 10 +++++---- 4 files changed, 29 insertions(+), 42 deletions(-) create mode 100644 partner_age/__manifest__.py delete mode 100644 partner_age/__openerp__.py diff --git a/partner_age/__manifest__.py b/partner_age/__manifest__.py new file mode 100644 index 0000000..a0b0a5b --- /dev/null +++ b/partner_age/__manifest__.py @@ -0,0 +1,22 @@ +# Copyright 2013-2018 Open Architects Consulting SPRL. +# Copyright 2018-Coop IT Easy SCRLfs () +# - Houssine BAKKALI - +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).# +{ + "name": "Partner Age", + "version": "12.0.1.0.0", + "depends": [ + "easy_my_coop", + "partner_contact_birthdate"], + "author": "Houssine BAKKALI ", + "category": "Cooperative management", + 'website': "www.coopiteasy.be", + "license": "AGPL-3", + "description": """ + This module computes the age of the partner. + """, + 'data': [ + 'view/partner_view.xml', + ], + 'installable': True, +} diff --git a/partner_age/__openerp__.py b/partner_age/__openerp__.py deleted file mode 100644 index 912b941..0000000 --- a/partner_age/__openerp__.py +++ /dev/null @@ -1,37 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# Copyright (C) 2013-2017 Open Architects Consulting SPRL. -# Copyright (C) 2018- Coop IT Easy SCRLfs. -# -# 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": "Partner Age", - "version": "1.0", - "depends": [ - "easy_my_coop", - "partner_contact_birthdate"], - "author": "Houssine BAKKALI ", - "category": "Cooperative management", - 'website': "www.coopiteasy.be", - "description": """ - This module computes the age of the partner. - """, - 'data': [ - 'view/partner_view.xml', - ], - 'installable': True, -} diff --git a/partner_age/models/__init__.py b/partner_age/models/__init__.py index 3f4a5ff..6bfcc71 100644 --- a/partner_age/models/__init__.py +++ b/partner_age/models/__init__.py @@ -1 +1 @@ -from . import partner \ No newline at end of file +from . import partner diff --git a/partner_age/models/partner.py b/partner_age/models/partner.py index d905c99..5d27b53 100644 --- a/partner_age/models/partner.py +++ b/partner_age/models/partner.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from datetime import datetime from openerp.tools import DEFAULT_SERVER_DATE_FORMAT as OE_DFORMAT @@ -11,8 +10,10 @@ class ResPartner(models.Model): def _search_age(self, operator, value): if operator not in ('=', '!=', '<', '<=', '>', '>=', 'in', 'not in'): return [] - # retrieve all the messages that match with a specific SQL query - query = """SELECT id FROM "%s" WHERE extract(year from age(CURRENT_DATE, birthdate_date)) %s %%s""" % \ + query = """SELECT id + FROM "%s" + WHERE extract(year from age(CURRENT_DATE, + birthdate_date)) %s %%s""" % \ (self._table, operator) self.env.cr.execute(query, (value,)) ids = [t[0] for t in self.env.cr.fetchall()] @@ -22,7 +23,8 @@ class ResPartner(models.Model): @api.depends('birthdate_date') def _compute_age(self): if self.birthdate_date: - dBday = datetime.strptime(self.birthdate_date, OE_DFORMAT).date() + dBday = datetime.strptime(str(self.birthdate_date), + OE_DFORMAT).date() dToday = datetime.now().date() self.age = dToday.year - dBday.year - (( dToday.month, dToday.day) < (dBday.month, dBday.day))