Skip to content

Commit

Permalink
[MIG] Migration partner_contact_birthdate partner_contact_gender part… (
Browse files Browse the repository at this point in the history
OCA#315)

[MIG] Migration partner_contact_birthdate partner_contact_gender partner_contact_personal_information_page to v10

Signed-off-by: Carmen Bianca Bakker <carmen@coopiteasy.be>
  • Loading branch information
invitu authored and carmenbianca committed Oct 10, 2022
1 parent c0ae238 commit 97d9fb6
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 30 deletions.
1 change: 1 addition & 0 deletions partner_contact_birthdate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
# Copyright (C) 2014-2015 Grupo ESOC <www.grupoesoc.es>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import models
from .hooks import post_init_hook
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
5 changes: 0 additions & 5 deletions partner_contact_birthdate/data/res_partner.yml

This file was deleted.

10 changes: 10 additions & 0 deletions partner_contact_birthdate/hooks.py
Original file line number Diff line number Diff line change
@@ -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()
9 changes: 2 additions & 7 deletions partner_contact_birthdate/models/res_partner.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2014-2015 Grupo ESOC <www.grupoesoc.es>
# 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"

Expand Down Expand Up @@ -36,8 +36,3 @@ def _birthdate_inverse(self):
_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()
28 changes: 13 additions & 15 deletions partner_contact_birthdate/views/res_partner.xml
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
© 2015 Grupo ESOC Ingeniería de Servicios, S.L.U. -->

<odoo>

<record id="view_personal_information_birthdate_date" model="ir.ui.view">
<field name="name">Birthdate Date field</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="partner_contact_personal_information_page.personal_information"/>
<field name="arch" type="xml">
<data>
<xpath expr="//group[@name='personal_information_group']">
<field name="birthdate_date"/>
</xpath>
</data>
</field>
</record>

<odoo>
<record id="view_personal_information_birthdate_date" model="ir.ui.view">
<field name="name">Birthdate Date field</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="partner_contact_personal_information_page.personal_information"/>
<field name="arch" type="xml">
<data>
<xpath expr="//group[@name='personal_information_group']">
<field name="birthdate_date"/>
</xpath>
</data>
</field>
</record>
</odoo>

0 comments on commit 97d9fb6

Please sign in to comment.