From 541c707e5fb888113610358a875891a76acb936f Mon Sep 17 00:00:00 2001 From: Jairo Llopis Date: Wed, 30 Dec 2015 18:41:01 +0100 Subject: [PATCH] Fix KeyError: 'substate_id_level'. --- base_location_nuts/models/res_partner.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/base_location_nuts/models/res_partner.py b/base_location_nuts/models/res_partner.py index a1117d689..fef97cd9a 100644 --- a/base_location_nuts/models/res_partner.py +++ b/base_location_nuts/models/res_partner.py @@ -50,19 +50,21 @@ class ResPartner(models.Model): @api.onchange("country_id") def _onchange_country_id(self): """Sensible values and domains for related fields.""" - fields = {"state_id", "region_id", "substate_id"} + fields = {"state", "region", "substate"} country_domain = ([("country_id", "=", self.country_id.id)] if self.country_id else []) domain = dict() for field in fields: + field += "_id" if self.country_id and self[field].country_id != self.country_id: self[field] = False domain[field] = list(country_domain) # Using list() to copy - fields.remove("state_id") + fields.remove("state") for field in fields: level = self.country_id["%s_level" % field] + field += "_id" if level: domain[field].append(("level", "=", level))