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.

30 lines
917 B

  1. # -*- coding: utf-8 -*-
  2. # Copyright 2016 Nicolas Bessi, Camptocamp SA
  3. # Copyright 2018 Tecnativa - Pedro M. Baeza
  4. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  5. from odoo import models, fields, api
  6. class ResCompany(models.Model):
  7. _inherit = 'res.company'
  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. help='Use the city name or the zip code to search the location',
  19. )
  20. @api.onchange('state_id')
  21. def onchange_state_id(self):
  22. if self.state_id.country_id:
  23. self.country_id = self.state_id.country_id.id