From 5158082a5cb2476a907bfd99eab769463e3a6655 Mon Sep 17 00:00:00 2001 From: houssine Date: Sun, 8 Oct 2017 19:23:59 +0200 Subject: [PATCH] [FIX] apply patch from tfrancois for the birthdate data loss --- easy_my_coop/models/partner.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/easy_my_coop/models/partner.py b/easy_my_coop/models/partner.py index c77de86..c02ad59 100644 --- a/easy_my_coop/models/partner.py +++ b/easy_my_coop/models/partner.py @@ -1,9 +1,21 @@ # -*- coding: utf-8 -*- from openerp import api, fields, models, _ +from datetime import date class ResPartner(models.Model): _inherit = 'res.partner' + def _auto_init(self, cr, context=None): + """ + Convert the column birthdate into date if it's not the case to avoid warning and data loss with orm conversion + """ + cr.execute("select data_type from information_schema.columns where table_name = 'res_partner' and column_name= 'birthdate';") + res = cr.fetchone() + if not 'date' in res: + cr.execute("ALTER TABLE res_partner ALTER COLUMN birthdate TYPE date USING birthdate::date;") + + super(ResPartner, self)._auto_init(cr, context=context) + @api.multi def _invoice_total(self): account_invoice_report = self.env['account.invoice.report']