Browse Source

set birthdate to user lang date_format if exist

pull/548/head
Mariam Flayyan 7 years ago
parent
commit
97c59c9767
  1. 8
      partner_contact_birthdate/models/res_partner.py

8
partner_contact_birthdate/models/res_partner.py

@ -1,6 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (C) 2014-2015 Grupo ESOC <www.grupoesoc.es> # Copyright (C) 2014-2015 Grupo ESOC <www.grupoesoc.es>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from datetime import datetime
from odoo import api, fields, models from odoo import api, fields, models
import logging import logging
@ -30,4 +31,9 @@ class ResPartner(models.Model):
@api.one @api.one
def _birthdate_inverse(self): def _birthdate_inverse(self):
"""Convert the old Char date to the new Date format.""" """Convert the old Char date to the new Date format."""
self.birthdate_date = self.birthdate
try:
self.birthdate_date = self.birthdate
except ValueError:
date_format = self.env['res.lang']._lang_get(
self.env.lang).date_format
self.birthdate_date = datetime.strptime(self.birthdate, date_format)
Loading…
Cancel
Save