diff --git a/partner_age/__openerp__.py b/partner_age/__openerp__.py index 25b24cc..ab7fd0f 100644 --- a/partner_age/__openerp__.py +++ b/partner_age/__openerp__.py @@ -21,7 +21,9 @@ { "name": "Partner Age", "version": "1.0", - "depends": ["easy_my_coop"], + "depends": [ + "easy_my_coop", + "partner_contact_birthdate"], "author": "Houssine BAKKALI ", "category": "Cooperative management", 'website': "www.coopiteasy.be", diff --git a/partner_age/models/partner.py b/partner_age/models/partner.py index a3bddf9..74e7bb2 100644 --- a/partner_age/models/partner.py +++ b/partner_age/models/partner.py @@ -11,17 +11,17 @@ class ResPartner(models.Model): 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)) %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()] return [('id', 'in', ids)] @api.one - @api.depends('birthdate') + @api.depends('birthdate_date') def _compute_age(self): - if self.birthdate: - dBday = datetime.strptime(self.birthdate, OE_DFORMAT).date() + if self.birthdate_date: + dBday = datetime.strptime(self.birthdate_date, OE_DFORMAT).date() dToday = datetime.now().date() self.age = dToday.year - dBday.year - (( dToday.month, dToday.day) < (dBday.month, dBday.day))