OCA/l10n-ecuador

View on GitHub
l10n_ec_ote/models/res_partner.py

Summary

Maintainability
A
0 mins
Test Coverage
# -*- coding: utf-8 -*-
from odoo import models, fields, api


class ResPartner(models.Model):
    _inherit = 'res.partner'

    @api.multi
    @api.onchange("canton_id")
    def _onchange_canton_id(self):
        for r in self:
            if r.canton_id and not r.city:
                r.city = r.canton_id.name.capitalize() or ''

    canton_id = fields.Many2one(
        'l10n_ec_ote.canton', ondelete='restrict', string="Canton", )
    parish_id = fields.Many2one(
        'l10n_ec_ote.parish', ondelete='restrict', string="Parish", )