Skip to content

Commit

Permalink
[FIX] Fixes error on onchange that fails when the record is created a…
Browse files Browse the repository at this point in the history
…nd no canton_id has been selected yet
  • Loading branch information
damendieta committed Nov 23, 2016
1 parent 33d5c37 commit 6b81068
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion l10n_ec_ote/models/res_company.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class ResCompany(models.Model):
@api.onchange("canton_id")
def _onchange_canton_id(self):
for r in self:
if not r.city:
if r.canton_id and not r.city:
r.city = r.canton_id.name.capitalize() or ''

country_id = fields.Many2one(default="base.ec", )
Expand Down
2 changes: 1 addition & 1 deletion l10n_ec_ote/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class ResPartner(models.Model):
@api.onchange("canton_id")
def _onchange_canton_id(self):
for r in self:
if not r.city:
if r.canton_id and not r.city:
r.city = r.canton_id.name.capitalize() or ''

country_id = fields.Many2one(default="base.ec", )
Expand Down

0 comments on commit 6b81068

Please sign in to comment.