diff --git a/base_location/__manifest__.py b/base_location/__manifest__.py index ab99a039d..1d4810eba 100644 --- a/base_location/__manifest__.py +++ b/base_location/__manifest__.py @@ -1,9 +1,10 @@ # Copyright 2016 Nicolas Bessi, Camptocamp SA +# Copyright 2018 Tecnativa - Pedro M. Baeza # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { 'name': 'Location management (aka Better ZIP)', - 'version': '11.0.1.0.0', + 'version': '11.0.1.0.1', 'depends': [ 'base_address_city' ], diff --git a/base_location/models/company.py b/base_location/models/company.py index 3c0e78560..1016a1d23 100644 --- a/base_location/models/company.py +++ b/base_location/models/company.py @@ -1,4 +1,5 @@ # Copyright 2016 Nicolas Bessi, Camptocamp SA +# Copyright 2018 Tecnativa - Pedro M. Baeza # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo import models, fields, api @@ -62,3 +63,8 @@ class ResCompany(models.Model): self.state_id = self.city_id.state_id else: self.state_id = self.zip_id.state_id + + @api.onchange('state_id') + def onchange_state_id(self): + if self.state_id.country_id: + self.country_id = self.state_id.country_id.id diff --git a/base_location/models/partner.py b/base_location/models/partner.py index 61e172920..befddd1ff 100644 --- a/base_location/models/partner.py +++ b/base_location/models/partner.py @@ -1,4 +1,5 @@ # Copyright 2016 Nicolas Bessi, Camptocamp SA +# Copyright 2018 Tecnativa - Pedro M. Baeza # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo import api, fields, models, _ @@ -64,3 +65,8 @@ class ResPartner(models.Model): raise ValidationError(_( "The city of partner %s differs from that in " "location %s") % (rec.name, rec.zip_id.name)) + + @api.onchange('state_id') + def onchange_state_id(self): + if self.state_id.country_id: + self.country_id = self.state_id.country_id.id