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.

42 lines
1.3 KiB

4 years ago
  1. # Copyright (C) 2020 Open Source Integrators
  2. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  3. from odoo import api, fields, models
  4. class Animal(models.Model):
  5. _name = "animal"
  6. _description = "Animal"
  7. _inherit = ["mail.thread", "mail.activity.mixin"]
  8. _order = "name"
  9. name = fields.Char(string="Name")
  10. ref = fields.Char(string="Reference")
  11. species_id = fields.Many2one("animal.species", string="Species", required=True)
  12. breed_id = fields.Many2one("animal.breed", string="Breed", required=True)
  13. color_id = fields.Many2one("animal.color", string="Color")
  14. size = fields.Char(string="Size")
  15. weight = fields.Float(string="Weight (in kg)")
  16. birth_date = fields.Date(string="Birth Date")
  17. gender = fields.Selection(
  18. string="Gender",
  19. selection=[
  20. ("female", "Female"),
  21. ("male", "Male"),
  22. ("hermaphrodite", "Hermaphrodite"),
  23. ("neutered", "Neutered"),
  24. ],
  25. default="female",
  26. required=True,
  27. )
  28. active = fields.Boolean(default=True)
  29. image = fields.Binary(
  30. "Image", attachment=True, help="This field holds the photo of the animal."
  31. )
  32. @api.onchange("species_id")
  33. def onchange_species(self):
  34. self.breed_id = False
  35. @api.onchange("breed_id")
  36. def onchange_breed(self):
  37. self.color_id = False