specie.py 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. # -*- coding: utf-8 -*-
  2. # @authors: Alexander Ezquevo <alexander@acysos.com>
  3. # Copyright (C) 2015 Acysos S.L.
  4. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  5. from openerp import models, fields, api
  6. class Specie(models.Model):
  7. _name = 'farm.specie'
  8. name = fields.Char(string='name', traslate=True, required=True,
  9. help='Name of the specie. ie. "Pig"')
  10. male_product = fields.Many2one(
  11. comodel_name='product.product', string="Male's Product")
  12. male_enabled = fields.Boolean(
  13. string='Males Enabled',
  14. default=True, )
  15. female_product = fields.Many2one(
  16. comodel_name='product.product',
  17. string="Female's Product", )
  18. female_enabled = fields.Boolean(
  19. string='Females Enabled',
  20. default=True, )
  21. individual_product = fields.Many2one(
  22. comodel_name='product.product',
  23. string="Individual's Product", )
  24. individual_enabled = fields.Boolean(
  25. string='Individuals Enabled', default=True, )
  26. group_product = fields.Many2one(
  27. comodel_name='product.product', string="Group's Product")
  28. group_enabled = fields.Boolean(
  29. string='Groups Enabled', default=True, )
  30. semen_product = fields.Many2one(
  31. comodel_name='product.product', string="Semen's Product",
  32. help="Product for the mixture of semen to raise the expected "
  33. "quality.\nIt is used in the Production lots produced in the "
  34. "Extraction Events and in the BoM containers for doses used in "
  35. "deliveries to farms for inseminations.")
  36. sale_product = fields.Many2one(comodel_name='product.product',
  37. string='Product denomination in sales',
  38. help='use when you sale animal units but'
  39. ' customer pay meat kilogram')
  40. breeds = fields.One2many(comodel_name='farm.specie.breed',
  41. inverse_name='specie', string='Breeds')
  42. farm_lines = fields.One2many(comodel_name='farm.specie.farm_line',
  43. inverse_name='specie', string='Farms')
  44. removed_location = fields.Many2one(
  45. comodel_name='stock.location', string='Removed Location',
  46. domain=[('usage', '=', 'transit')],
  47. required=True,
  48. help='Virtual location where removed animals are moved to.')
  49. foster_location = fields.One2many(
  50. comodel_name='farm.foster.locations', inverse_name='specie',
  51. string='Foster Location',
  52. help='Virtual location where fostered animals are moved to.')
  53. lost_found_location = fields.One2many(
  54. comodel_name='farm.transit.locations', inverse_name='specie',
  55. string='Transit Location',
  56. help='Virtual location where lost or found animals are moved to.')
  57. future_maders_location = fields.One2many(
  58. comodel_name='farm.future_maders.locations', inverse_name='specie',
  59. string='Future maders location')
  60. feed_lost_found_location = fields.Many2one(
  61. comodel_name='stock.location', inverse_name='specie',
  62. string='Feed transit',
  63. domain=[('usage', '=', 'transit')])
  64. consumed_feed_location = fields.Many2one(
  65. comodel_name='stock.location', string='consumed feed location',
  66. domain=[('usage', '=', 'inventory'), ('scrap_location', '=', True)],
  67. required=True)
  68. @api.onchange('male_enabled')
  69. def onChange_male_enabled(self):
  70. if self.male_enabled is False:
  71. self.male_product = False
  72. @api.onchange('female_enabled')
  73. def onChange_female_enabled(self):
  74. if self.female_enabled is False:
  75. self.female_product = False
  76. @api.onchange('individual_enabled')
  77. def onChange_individual_enabled(self):
  78. if self.individual_enabled is False:
  79. self.individual_product = False
  80. @api.onchange('individual_enabled')
  81. def onChange_group_enabled(self):
  82. if self.group_enabled is False:
  83. self.group_product = False
  84. class Breed(models.Model):
  85. 'Breed of Specie'
  86. _name = 'farm.specie.breed'
  87. specie = fields.Many2one(comodel_name='farm.specie',
  88. string='Specie', required=True,
  89. ondelete='CASCADE')
  90. name = fields.Char(string='Name', required=True)
  91. class SpecieFarmLine(models.Model):
  92. 'Managed Farm of specie'
  93. _name = 'farm.specie.farm_line'
  94. specie = fields.Many2one(comodel_name='farm.specie',
  95. string='Specie', required=True,
  96. ondelete='CASCADE')
  97. farm = fields.Many2one(comodel_name='stock.location',
  98. string='Farm', required=True,
  99. domain=[('usage', '=', 'view')])
  100. event_order_sequence = fields.Many2one(
  101. comodel_name='ir.sequence',
  102. string="Events Orders' Sequence", required=True, domain=[
  103. ('code', '=', 'farm.event.order')
  104. ],
  105. help="Sequence used for the Event Orders in this farm.")
  106. has_male = fields.Boolean(string='Males',
  107. help="In this farm there are males.")
  108. male_sequence = fields.Many2one(
  109. comodel_name='ir.sequence', string="Males' Sequence",
  110. domain=[('code', '=', 'farm.animal')],
  111. help='Sequence used for male lots and animals.')
  112. semen_lot_sequence = fields.Many2one(
  113. comodel_name='ir.sequence',
  114. string="Extracted Semen Lots' Sequence",
  115. domain=[('code', '=', 'stock.lot')])
  116. dose_lot_sequence = fields.Many2one(
  117. comodel_name='ir.sequence',
  118. string="Semen Dose Lots' Sequence",
  119. domain=[('code', '=', 'stock.lot')])
  120. has_female = fields.Boolean(string='Females',
  121. help="In this farm there are females.")
  122. female_sequence = fields.Many2one(
  123. comodel_name='ir.sequence', string="Females' Sequence",
  124. domain=[('code', '=', 'farm.animal')],
  125. help='Sequence used for female production lots and animals.')
  126. has_individual = fields.Boolean(string='Individuals',
  127. help="In this farm there are individuals.")
  128. individual_sequence = fields.Many2one(
  129. comodel_name='ir.sequence',
  130. string="Individuals' Sequence", domain=[('code', '=', 'farm.animal')],
  131. help="Sequence used for individual lots and animals.")
  132. has_group = fields.Boolean(string='Groups',
  133. help="In this farm there are groups.")
  134. group_sequence = fields.Many2one(
  135. comodel_name='ir.sequence', string="Groups' Sequence",
  136. domain=[('code', '=', 'farm.animal.group')],
  137. help='Sequence used for group production lots and animals.')
  138. class SpecieModel(models.Model):
  139. 'Specie - Model'
  140. _name = 'farm.specie.ir.model'
  141. specie = fields.Many2one(comodel_name='farm.specie', string='Specie',
  142. ondelete='CASCADE',
  143. required=True, select=True)
  144. model = fields.Many2one(comodel_name='ir.model', string='Model',
  145. required=True, select=True)