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.

27 lines
1014 B

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. # Copyright 2015 Antonio Espinosa <antonio.espinosa@tecnativa.com>
  2. # Copyright 2016 Jairo Llopis <jairo.llopis@tecnativa.com>
  3. # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
  4. from odoo import fields, models
  5. class ResPartnerNuts(models.Model):
  6. _name = "res.partner.nuts"
  7. _order = "parent_path"
  8. _parent_order = "name"
  9. _parent_store = True
  10. _description = "NUTS Item"
  11. # NUTS fields
  12. level = fields.Integer(required=True)
  13. code = fields.Char(required=True)
  14. name = fields.Char(required=True, translate=True)
  15. country_id = fields.Many2one(comodel_name="res.country", required=True)
  16. state_id = fields.Many2one(comodel_name="res.country.state")
  17. not_updatable = fields.Boolean()
  18. # Parent hierarchy
  19. parent_id = fields.Many2one(comodel_name="res.partner.nuts", ondelete="restrict")
  20. parent_path = fields.Char(index=True)
  21. child_ids = fields.One2many(
  22. comodel_name="res.partner.nuts", inverse_name="parent_id", string="Children"
  23. )