Browse Source

[IMP] base_location: Include onchange for state

Incredibly not included in Odoo core.
pull/638/head
Pedro M. Baeza 7 years ago
parent
commit
0d3b5087a8
  1. 3
      base_location/__openerp__.py
  2. 6
      base_location/models/company.py
  3. 6
      base_location/models/partner.py

3
base_location/__openerp__.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'
],

6
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

6
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
Loading…
Cancel
Save