diff --git a/partner_firstname/__init__.py b/partner_firstname/__init__.py index 8a9bba4af..b3bc449ef 100644 --- a/partner_firstname/__init__.py +++ b/partner_firstname/__init__.py @@ -1,4 +1,6 @@ # -*- coding: utf-8 -*- # © 2013 Nicolas Bessi (Camptocamp SA) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + from . import models +from .hooks import post_init_hook diff --git a/partner_firstname/__manifest__.py b/partner_firstname/__manifest__.py index 16b6feae6..34561ed56 100644 --- a/partner_firstname/__manifest__.py +++ b/partner_firstname/__manifest__.py @@ -7,7 +7,7 @@ { 'name': 'Partner first name and last name', 'summary': "Split first name and last name for non company partners", - 'version': '10.0.2.0.0', + 'version': '10.0.2.1.0', 'author': "Camptocamp, " "Grupo ESOC Ingeniería de Servicios, " "Tecnativa, " @@ -19,11 +19,11 @@ 'category': 'Extra Tools', 'website': 'https://odoo-community.org/', 'depends': ['base_setup'], + 'post_init_hook': 'post_init_hook', 'data': [ 'views/base_config_view.xml', 'views/res_partner.xml', 'views/res_user.xml', - 'data/res_partner.yml', ], 'auto_install': False, 'installable': True, diff --git a/partner_firstname/data/res_partner.yml b/partner_firstname/data/res_partner.yml deleted file mode 100644 index a88e01841..000000000 --- a/partner_firstname/data/res_partner.yml +++ /dev/null @@ -1,19 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright (C) -# 2015: Grupo ESOC -# -# 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 . - -- !function {model: res.partner, name: _install_partner_firstname} diff --git a/partner_firstname/hooks.py b/partner_firstname/hooks.py new file mode 100644 index 000000000..64c0b7a9f --- /dev/null +++ b/partner_firstname/hooks.py @@ -0,0 +1,11 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 LasLabs Inc. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import api, SUPERUSER_ID + + +def post_init_hook(cr, _): + with api.Environment.manage(): + env = api.Environment(cr, SUPERUSER_ID, {}) + env['res.partner']._install_partner_firstname() diff --git a/partner_firstname/models/res_partner.py b/partner_firstname/models/res_partner.py index e27997841..b9b6bfe7d 100644 --- a/partner_firstname/models/res_partner.py +++ b/partner_firstname/models/res_partner.py @@ -14,8 +14,14 @@ class ResPartner(models.Model): """Adds last name and first name; name becomes a stored function field.""" _inherit = 'res.partner' - firstname = fields.Char("First name") - lastname = fields.Char("Last name") + firstname = fields.Char( + "First name", + index=True, + ) + lastname = fields.Char( + "Last name", + index=True, + ) name = fields.Char( compute="_compute_name", inverse="_inverse_name_after_cleaning_whitespace",