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.

24 lines
769 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 ResPartner(models.Model):
  7. _inherit = 'res.partner'
  8. zip_id = fields.Many2one('res.better.zip', 'City/Location')
  9. @api.onchange('zip_id')
  10. def onchange_zip_id(self):
  11. if self.zip_id:
  12. self.zip = self.zip_id.name
  13. self.city = self.zip_id.city
  14. self.state_id = self.zip_id.state_id
  15. self.country_id = self.zip_id.country_id
  16. @api.onchange('state_id')
  17. def onchange_state_id(self):
  18. if self.state_id.country_id:
  19. self.country_id = self.state_id.country_id.id