You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
610 B

  1. # Copyright 2018 Aitor Bouzas <aitor.bouzas@adaptivecity.com>
  2. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  3. from odoo import fields, models
  4. class City(models.Model):
  5. _inherit = "res.city"
  6. zip_ids = fields.One2many("res.city.zip", "city_id", string="Zips in this city")
  7. _sql_constraints = [
  8. (
  9. "name_state_country_uniq",
  10. "UNIQUE(name, state_id, country_id)",
  11. "You already have a city with that name in the same state."
  12. "The city must have a unique name within "
  13. "it's state and it's country",
  14. )
  15. ]