Browse Source

[IMP] partner_firstname: Add indices

* Add index to first and last name in order to allow for quicker searches - fixing an incredibly slow update time with large dbs

[IMP] partner_firstname: Only run install function on update
* Remove yml data file for install and move method to init hook
* Bump version
pull/663/head
Dave Lasley 7 years ago
committed by Jairo Llopis
parent
commit
fbc313f6bc
  1. 2
      partner_firstname/__init__.py
  2. 4
      partner_firstname/__manifest__.py
  3. 19
      partner_firstname/data/res_partner.yml
  4. 11
      partner_firstname/hooks.py
  5. 10
      partner_firstname/models/res_partner.py

2
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

4
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,

19
partner_firstname/data/res_partner.yml

@ -1,19 +0,0 @@
# -*- coding: utf-8 -*-
# Copyright (C)
# 2015: Grupo ESOC <www.grupoesoc.es>
#
# 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 <http://www.gnu.org/licenses/>.
- !function {model: res.partner, name: _install_partner_firstname}

11
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()

10
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",

Loading…
Cancel
Save