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.

26 lines
758 B

  1. # -*- coding: utf-8 -*-
  2. # Copyright 2016 Nicolas Bessi, Copyright Camptocamp SA
  3. # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
  4. from openerp import models, fields, api
  5. class ResCompany(models.Model):
  6. _inherit = 'res.company'
  7. @api.one
  8. @api.onchange('better_zip_id')
  9. def on_change_city(self):
  10. if self.better_zip_id:
  11. self.zip = self.better_zip_id.name
  12. self.city = self.better_zip_id.city
  13. self.state_id = self.better_zip_id.state_id
  14. self.country_id = self.better_zip_id.country_id
  15. better_zip_id = fields.Many2one(
  16. 'res.better.zip',
  17. string='Location',
  18. select=1,
  19. help='Use the city name or the zip code to search the location',
  20. )