forked from OCA/partner-contact
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hooks.py
25 lines (21 loc) · 917 Bytes
/
hooks.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# -*- coding: utf-8 -*-
# Copyright 2013-2015 Therp BV (<http://therp.nl>)
# Copyright 2016 Onestein (<http://www.onestein.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import logging
from odoo import SUPERUSER_ID, api
def post_init_hook(cr, registry):
"""
Post-install script. Because 'street' is now a stored function field, we
should be able to retrieve its values from the cursor. We use those to
fill the new name/number fields using the street field's inverse function,
which does a basic street name/number split.
"""
logging.getLogger('odoo.addons.partner_street_number').info(
'Migrating existing street names')
env = api.Environment(cr, SUPERUSER_ID, {})
partners = env['res.partner'].with_context(active_test=False).search([
('street', '!=', False),
('street_name', '=', False)
])
partners._write_street()