You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
917 B

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