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.

57 lines
2.0 KiB

7 years ago
  1. # -*- coding: utf-8 -*-
  2. ##############################################################################
  3. #
  4. # Author: Romain Deheele
  5. # Copyright 2014 Camptocamp SA
  6. #
  7. # Author: Quentin Theuret
  8. # Copyright 2017 SenseFly, Amaris
  9. #
  10. # This program is free software: you can redistribute it and/or modify
  11. # it under the terms of the GNU Affero General Public License as
  12. # published by the Free Software Foundation, either version 3 of the
  13. # License, or (at your option) any later version.
  14. #
  15. # This program is distributed in the hope that it will be useful,
  16. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. # GNU Affero General Public License for more details.
  19. #
  20. # You should have received a copy of the GNU Affero General Public License
  21. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. #
  23. ##############################################################################
  24. from odoo import models, fields
  25. class Continent(models.Model):
  26. _name = 'res.continent'
  27. _description = 'Continent'
  28. _order = 'name'
  29. name = fields.Char(string='Continent Name', translate=True,
  30. help='The full name of the continent', required=True)
  31. code = fields.Char(string='Continent Code', size=2, required=True)
  32. countries = fields.One2many(comodel_name='res.country',
  33. inverse_name='continent_id', string='Countries', readonly=True)
  34. class Country(models.Model):
  35. _inherit = 'res.country'
  36. continent_id = fields.Many2one(comodel_name='res.continent', string='Continent')
  37. class Partner(models.Model):
  38. _inherit = 'res.partner'
  39. continent_id = fields.Many2one(comodel_name='res.continent', string='Continent',
  40. readonly=True, store=True, related='country_id.continent_id')
  41. class Company(models.Model):
  42. _inherit = 'res.company'
  43. continent_id = fields.Many2one(comodel_name='res.continent', string='Continent',
  44. readonly=True, store=True, related='country_id.continent_id')