Added a wizard to update the value of the observation field for an specific cycle
This commit is contained in:
parent
f85a312539
commit
53c763cdec
|
@ -34,6 +34,7 @@ def register():
|
|||
animal.Female,
|
||||
animal.CreateFemaleStart,
|
||||
animal.CreateFemaleLine,
|
||||
animal.ChangeCycleObservationStart,
|
||||
animal_group.AnimalGroup,
|
||||
animal_group.AnimalGroupTag,
|
||||
animal_group.AnimalGroupWeight,
|
||||
|
@ -76,4 +77,5 @@ def register():
|
|||
module='farm', type_='model')
|
||||
Pool.register(
|
||||
animal.CreateFemale,
|
||||
animal.ChangeCycleObservation,
|
||||
module='farm', type_='wizard')
|
||||
|
|
64
animal.py
64
animal.py
|
@ -8,10 +8,11 @@ from trytond.model import ModelView, ModelSQL, fields
|
|||
from trytond.pyson import Equal, Eval, Greater, Id, Not, Bool
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
from trytond.wizard import Wizard, StateView, StateAction, Button
|
||||
from trytond.wizard import Wizard, StateView, StateAction, Button, StateTransition
|
||||
|
||||
__all__ = ['Tag', 'Animal', 'AnimalTag', 'AnimalWeight', 'Male', 'Female',
|
||||
'FemaleCycle', 'CreateFemaleStart', 'CreateFemaleLine', 'CreateFemale']
|
||||
'FemaleCycle', 'CreateFemaleStart', 'CreateFemaleLine', 'CreateFemale',
|
||||
'ChangeCycleObservationStart', 'ChangeCycleObservation']
|
||||
__metaclass__ = PoolMeta
|
||||
|
||||
_STATES_MALE_FIELD = {
|
||||
|
@ -640,6 +641,11 @@ class Female:
|
|||
'duplicate_animal': ('A female animal with the same number (%s) '
|
||||
'already exisit in this farm')
|
||||
})
|
||||
cls._buttons.update({
|
||||
'change_observation': {
|
||||
'invisible': Not(Bool(Eval('cycles'))),
|
||||
}
|
||||
})
|
||||
|
||||
@staticmethod
|
||||
def default_state():
|
||||
|
@ -650,6 +656,11 @@ class Female:
|
|||
return 'prospective'
|
||||
return None
|
||||
|
||||
@classmethod
|
||||
@ModelView.button_action('farm.wizard_farm_cycle_observation_female')
|
||||
def change_observation(cls, records):
|
||||
pass
|
||||
|
||||
def is_lactating(self):
|
||||
return (self.current_cycle and self.current_cycle.state == 'lactating'
|
||||
or False)
|
||||
|
@ -951,6 +962,7 @@ class FemaleCycle(ModelSQL, ModelView):
|
|||
fields.Integer('Lactating Days',
|
||||
help='Number of days between Farrowing and Weaning.'),
|
||||
'get_lactating_days')
|
||||
observations = fields.Text('Observations')
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
|
@ -1115,6 +1127,54 @@ class FemaleCycle(ModelSQL, ModelView):
|
|||
return super(FemaleCycle, cls).create(vlist)
|
||||
|
||||
|
||||
class ChangeCycleObservationStart(ModelView):
|
||||
'Sets the value of the observation field of a cycle'
|
||||
__name__ = 'female.cycle.observation.start'
|
||||
|
||||
cycle = fields.Many2One('farm.animal.female_cycle', 'Cycle',
|
||||
domain=[
|
||||
('animal', '=', Eval('animal'))
|
||||
],
|
||||
states={
|
||||
'required': True,
|
||||
})
|
||||
observation = fields.Text('Observation', required=True)
|
||||
animal = fields.Many2One('farm.animal', 'Current animal',
|
||||
readonly=True, states={
|
||||
'invisible': True,
|
||||
})
|
||||
|
||||
@staticmethod
|
||||
def default_cycle():
|
||||
Animal = Pool().get('farm.animal')
|
||||
active_id = Transaction().context.get('active_id')
|
||||
active_animal = Animal(active_id)
|
||||
last_cycle = active_animal.cycles[-1]
|
||||
return last_cycle.id
|
||||
|
||||
@staticmethod
|
||||
def default_animal():
|
||||
return Transaction().context.get('active_id')
|
||||
|
||||
|
||||
class ChangeCycleObservation(Wizard):
|
||||
'Sets the value of the observation field of a cycle'
|
||||
__name__ = 'female.cycle.observation'
|
||||
|
||||
start = StateView('female.cycle.observation.start',
|
||||
'farm.farm_cycle_observation_start_view', [
|
||||
Button('Cancel', 'end', 'tryton-cancel'),
|
||||
Button('Create', 'result', 'tryton-ok', default=True),
|
||||
])
|
||||
result = StateTransition()
|
||||
|
||||
def transition_result(self):
|
||||
cycle = self.start.cycle
|
||||
cycle.observations = self.start.observation
|
||||
cycle.save()
|
||||
return 'end'
|
||||
|
||||
|
||||
class CreateFemaleStart(ModelView):
|
||||
'Create Female Start'
|
||||
__name__ = 'farm.create_female.start'
|
||||
|
|
10
animal.xml
10
animal.xml
|
@ -314,6 +314,16 @@
|
|||
<field name="group" ref="group_farm_females"/>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="farm_cycle_observation_start_view">
|
||||
<field name="model">female.cycle.observation.start</field>
|
||||
<field name="type">form</field>
|
||||
<field name="name">farm_cycle_observation_start</field>
|
||||
</record>
|
||||
<record model="ir.action.wizard" id="wizard_farm_cycle_observation_female">
|
||||
<field name="name">Update Observations</field>
|
||||
<field name="wiz_name">female.cycle.observation</field>
|
||||
</record>
|
||||
|
||||
<!-- Menus -->
|
||||
<menuitem action="act_farm_tag" id="menu_farm_tag"
|
||||
parent="menu_configuration" sequence="2"/>
|
||||
|
|
|
@ -402,12 +402,6 @@ msgctxt "error:farm.removal.event:"
|
|||
msgid "The event '%s' can't be deleted because is not in 'Draft' state."
|
||||
msgstr ""
|
||||
|
||||
msgctxt "error:farm.removal.event:"
|
||||
msgid ""
|
||||
"The female of removal event \"%s\" is lactating. To remove it you have to "
|
||||
"create a weaning event or remove its produced group."
|
||||
msgstr ""
|
||||
|
||||
msgctxt "error:farm.removal.event:"
|
||||
msgid ""
|
||||
"The removal event of animal \"%(animal)s\" is trying to remove it from "
|
||||
|
|
116
locale/es_ES.po
116
locale/es_ES.po
|
@ -10,6 +10,10 @@ msgctxt "error:farm.abort.event-farm.animal.female_cycle:"
|
|||
msgid "The Female Cycle must be unique."
|
||||
msgstr "El ciclo de la hembra debe ser único."
|
||||
|
||||
msgctxt "error:farm.abort.event:"
|
||||
msgid "The date of the event is set in the future"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "error:farm.abort.event:"
|
||||
msgid "The event '%s' can't be deleted because is not in 'Draft' state."
|
||||
msgstr ""
|
||||
|
@ -19,10 +23,6 @@ msgctxt "error:farm.animal.female_cycle:"
|
|||
msgid "The date of the cycle is before the one of the precious cycle"
|
||||
msgstr "La fecha del ciclo es anterior a la del ciclo anterior"
|
||||
|
||||
msgctxt "error:farm.animal:"
|
||||
msgid "A female animal with the same number \"%s\" already exisit in this farm"
|
||||
msgstr "Una hembra con el mismo numero \"%s\" ya existe en esta granja"
|
||||
|
||||
msgctxt "error:farm.animal.group:"
|
||||
msgid ""
|
||||
"Supplier Location of company's party \"%s\" is empty but it is required to "
|
||||
|
@ -58,6 +58,10 @@ msgstr ""
|
|||
"El almacén \"%s\" no tiene definida la ubicación de producción, pero ésta se"
|
||||
" requiere para el movimiento de llegada del nuevo grupo."
|
||||
|
||||
msgctxt "error:farm.animal:"
|
||||
msgid "A female animal with the same number (%s) already exisit in this farm"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "error:farm.animal:"
|
||||
msgid ""
|
||||
"Supplier Location of company's party \"%s\" is empty but it is required to "
|
||||
|
@ -199,6 +203,10 @@ msgstr ""
|
|||
"La granja \"%(farm)s\" no se ha configurado como granja con "
|
||||
"\"%(animal_type)s\" para la especie \"%(specie)s\"."
|
||||
|
||||
msgctxt "error:farm.event:"
|
||||
msgid "The date of the event is set in the future"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "error:farm.event:"
|
||||
msgid "The event '%s' can't be deleted because is not in 'Draft' state."
|
||||
msgstr ""
|
||||
|
@ -220,6 +228,10 @@ msgctxt "error:farm.farrowing.event-farm.animal.group:"
|
|||
msgid "The Farrowing Event must be unique."
|
||||
msgstr "El evento de parto debe ser único."
|
||||
|
||||
msgctxt "error:farm.farrowing.event:"
|
||||
msgid "The date of the event is set in the future"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "error:farm.farrowing.event:"
|
||||
msgid "The event '%s' can't be deleted because is not in 'Draft' state."
|
||||
msgstr ""
|
||||
|
@ -264,6 +276,10 @@ msgctxt "error:farm.feed.event:"
|
|||
msgid "The Timestamp must be after the Start Date"
|
||||
msgstr "El campo Fecha & Hora debe ser posterior a la fecha de inicio"
|
||||
|
||||
msgctxt "error:farm.feed.event:"
|
||||
msgid "The date of the event is set in the future"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "error:farm.feed.event:"
|
||||
msgid "The event '%s' can't be deleted because is not in 'Draft' state."
|
||||
msgstr ""
|
||||
|
@ -373,6 +389,10 @@ msgstr ""
|
|||
"No hay ningún inventario de pienso prévio al inventario provisional \"%s\" "
|
||||
"que está intentando confirmar."
|
||||
|
||||
msgctxt "error:farm.foster.event:"
|
||||
msgid "The date of the event is set in the future"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "error:farm.foster.event:"
|
||||
msgid "The event '%s' can't be deleted because is not in 'Draft' state."
|
||||
msgstr ""
|
||||
|
@ -394,6 +414,10 @@ msgstr ""
|
|||
"El grupo parido de la hembra pareja de la adopción \"%(event)s\" no tiene "
|
||||
"%(quantity)s unidades en la ubicación \"%(location)s\" el \"%(timestamp)s\"."
|
||||
|
||||
msgctxt "error:farm.insemination.event:"
|
||||
msgid "The date of the event is set in the future"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "error:farm.insemination.event:"
|
||||
msgid "The event '%s' can't be deleted because is not in 'Draft' state."
|
||||
msgstr ""
|
||||
|
@ -426,6 +450,10 @@ msgctxt "error:farm.medication.event:"
|
|||
msgid "The Timestamp must be after the Start Date"
|
||||
msgstr "El camp Fecha & Hora debe ser posterior a la fecha de inicio."
|
||||
|
||||
msgctxt "error:farm.medication.event:"
|
||||
msgid "The date of the event is set in the future"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "error:farm.medication.event:"
|
||||
msgid "The event '%s' can't be deleted because is not in 'Draft' state."
|
||||
msgstr ""
|
||||
|
@ -483,6 +511,10 @@ msgctxt "error:farm.move.event:"
|
|||
msgid "In Move Events, the weight can't be zero"
|
||||
msgstr "En los eventos de movimiento el peso no puede ser cero."
|
||||
|
||||
msgctxt "error:farm.move.event:"
|
||||
msgid "The date of the event is set in the future"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "error:farm.move.event:"
|
||||
msgid "The event '%s' can't be deleted because is not in 'Draft' state."
|
||||
msgstr ""
|
||||
|
@ -507,6 +539,10 @@ msgstr ""
|
|||
"%(quantity)s animales de la ubicación\"%(from_location)s\", pero no hay "
|
||||
"suficientes allí en \"%(timestamp)s\"."
|
||||
|
||||
msgctxt "error:farm.pregnancy_diagnosis.event:"
|
||||
msgid "The date of the event is set in the future"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "error:farm.pregnancy_diagnosis.event:"
|
||||
msgid "The event '%s' can't be deleted because is not in 'Draft' state."
|
||||
msgstr ""
|
||||
|
@ -525,19 +561,15 @@ msgstr ""
|
|||
"En los eventos de eliminación la cantidad debe ser positiva (mayor o igual a"
|
||||
" 1)"
|
||||
|
||||
msgctxt "error:farm.removal.event:"
|
||||
msgid "The date of the event is set in the future"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "error:farm.removal.event:"
|
||||
msgid "The event '%s' can't be deleted because is not in 'Draft' state."
|
||||
msgstr ""
|
||||
"El evento '%s' no puede ser eliminado porqué no está en estado 'Borrador'."
|
||||
|
||||
msgctxt "error:farm.removal.event:"
|
||||
msgid ""
|
||||
"The female of removal event \"%s\" is lactating. To remove it you have to "
|
||||
"create a weaning event or remove its produced group."
|
||||
msgstr ""
|
||||
"La hembra del evento de eliminación \"%s\" está lactando. Para eliminarla "
|
||||
"debe crear un evento de destete o eliminar su grupo producido."
|
||||
|
||||
msgctxt "error:farm.removal.event:"
|
||||
msgid ""
|
||||
"The removal event of animal \"%(animal)s\" is trying to remove it from "
|
||||
|
@ -608,6 +640,10 @@ msgstr ""
|
|||
"El test de calidad \"%(test)s\" del evento de extracción de semen \"%(event)s\" no ha sido exitoso..\n"
|
||||
"Por favor, compruebe los valores e intentelo de nuevo."
|
||||
|
||||
msgctxt "error:farm.semen_extraction.event:"
|
||||
msgid "The date of the event is set in the future"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "error:farm.semen_extraction.event:"
|
||||
msgid "The event '%s' can't be deleted because is not in 'Draft' state."
|
||||
msgstr ""
|
||||
|
@ -674,6 +710,10 @@ msgstr ""
|
|||
"En los eventos de transformación la cantidad debe ser positiva (mayour o "
|
||||
"igual a 1)."
|
||||
|
||||
msgctxt "error:farm.transformation.event:"
|
||||
msgid "The date of the event is set in the future"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "error:farm.transformation.event:"
|
||||
msgid "The event '%s' can't be deleted because is not in 'Draft' state."
|
||||
msgstr ""
|
||||
|
@ -706,6 +746,10 @@ msgctxt "error:farm.weaning.event-farm.animal.female_cycle:"
|
|||
msgid "The Weaning Event must be unique."
|
||||
msgstr "El evento de destete debe ser único."
|
||||
|
||||
msgctxt "error:farm.weaning.event:"
|
||||
msgid "The date of the event is set in the future"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "error:farm.weaning.event:"
|
||||
msgid "The entered quantity is incorrect, the maximum allowed quantity is: %s"
|
||||
msgstr ""
|
||||
|
@ -1089,6 +1133,10 @@ msgctxt "field:farm.animal.female_cycle,live:"
|
|||
msgid "Live"
|
||||
msgstr "Vivos"
|
||||
|
||||
msgctxt "field:farm.animal.female_cycle,observations:"
|
||||
msgid "Observations"
|
||||
msgstr "Observaciones"
|
||||
|
||||
msgctxt "field:farm.animal.female_cycle,ordination_date:"
|
||||
msgid "Date for ordination"
|
||||
msgstr "Fecha para ordenación"
|
||||
|
@ -3562,6 +3610,22 @@ msgctxt "field:farm.weaning.event-farm.animal.female_cycle,write_uid:"
|
|||
msgid "Write User"
|
||||
msgstr "Usuario modificación"
|
||||
|
||||
msgctxt "field:female.cycle.observation.start,animal:"
|
||||
msgid "Current animal"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:female.cycle.observation.start,cycle:"
|
||||
msgid "Cycle"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:female.cycle.observation.start,id:"
|
||||
msgid "ID"
|
||||
msgstr "Identificador"
|
||||
|
||||
msgctxt "field:female.cycle.observation.start,observation:"
|
||||
msgid "Observation"
|
||||
msgstr "Observaciones"
|
||||
|
||||
msgctxt "field:ir.action.act_window,specie:"
|
||||
msgid "Specie"
|
||||
msgstr "Especie"
|
||||
|
@ -4428,6 +4492,10 @@ msgctxt "model:farm.weaning.event-farm.animal.female_cycle,name:"
|
|||
msgid "Weaning Event - Female Cycle"
|
||||
msgstr "Evento de destete - Ciclo hembras"
|
||||
|
||||
msgctxt "model:female.cycle.observation.start,name:"
|
||||
msgid "Sets the value of the observation field of a cycle"
|
||||
msgstr "Pone el valor del campo de observacion de un ciclo"
|
||||
|
||||
msgctxt "model:ir.action,name:act_farm_abort_event"
|
||||
msgid "Aborts"
|
||||
msgstr "Abortos"
|
||||
|
@ -4544,6 +4612,10 @@ msgctxt "model:ir.action,name:wizard_farm_create_female"
|
|||
msgid "Create female"
|
||||
msgstr "Crear hembra"
|
||||
|
||||
msgctxt "model:ir.action,name:wizard_farm_cycle_observation_female"
|
||||
msgid "Update Observations"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "model:ir.sequence.type,name:sequence_type_animal"
|
||||
msgid "Farm Animal"
|
||||
msgstr "Animal"
|
||||
|
@ -5395,6 +5467,10 @@ msgctxt "view:farm.animal.female_cycle:"
|
|||
msgid "Female Cycles"
|
||||
msgstr "Ciclo hembra"
|
||||
|
||||
msgctxt "view:farm.animal.female_cycle:"
|
||||
msgid "Observations"
|
||||
msgstr "Observaciones"
|
||||
|
||||
msgctxt "view:farm.animal.group.weight:"
|
||||
msgid "Weight"
|
||||
msgstr "Peso"
|
||||
|
@ -5435,6 +5511,10 @@ msgctxt "view:farm.animal:"
|
|||
msgid "Animals"
|
||||
msgstr "Animales"
|
||||
|
||||
msgctxt "view:farm.animal:"
|
||||
msgid "Change Cycle Observation"
|
||||
msgstr "Cambiar observación"
|
||||
|
||||
msgctxt "view:farm.animal:"
|
||||
msgid "General"
|
||||
msgstr "General"
|
||||
|
@ -5616,6 +5696,10 @@ msgctxt "view:farm.tag:"
|
|||
msgid "Tags"
|
||||
msgstr "Etiquetas"
|
||||
|
||||
msgctxt "view:female.cycle.observation.start:"
|
||||
msgid "Create Female"
|
||||
msgstr "Crear hembra"
|
||||
|
||||
msgctxt "view:res.user:"
|
||||
msgid "Farm"
|
||||
msgstr "Granja"
|
||||
|
@ -5643,3 +5727,11 @@ msgstr "Cancelar"
|
|||
msgctxt "wizard_button:farm.create_female,start,result:"
|
||||
msgid "Create"
|
||||
msgstr "Crear"
|
||||
|
||||
msgctxt "wizard_button:female.cycle.observation,start,end:"
|
||||
msgid "Cancel"
|
||||
msgstr "Cancel·lar"
|
||||
|
||||
msgctxt "wizard_button:female.cycle.observation,start,result:"
|
||||
msgid "Create"
|
||||
msgstr "Crear"
|
||||
|
|
|
@ -22,24 +22,31 @@
|
|||
<label name="removed"/>
|
||||
<field name="removed"/>
|
||||
</group>
|
||||
<separator id="events" string="Events" colspan="4"/>
|
||||
<field name="insemination_events" colspan="4"/>
|
||||
<field name="diagnosis_events" colspan="4"/>
|
||||
<group id="abort_and_farrowing" colspan="4" col="6">
|
||||
<label name="abort_event"/>
|
||||
<field name="abort_event"/>
|
||||
<newline/>
|
||||
<label name="farrowing_event"/>
|
||||
<field name="farrowing_event"/>
|
||||
<label name="live"/>
|
||||
<field name="live"/>
|
||||
<label name="dead"/>
|
||||
<field name="dead"/>
|
||||
</group>
|
||||
<field name="foster_events" colspan="4"/>
|
||||
<newline/>
|
||||
<label name="weaning_event"/>
|
||||
<field name="weaning_event"/>
|
||||
<label name="weaned"/>
|
||||
<field name="weaned"/>
|
||||
<notebook>
|
||||
<page id="inseminations" string="Events">
|
||||
<field name="insemination_events" colspan="4"/>"
|
||||
<field name="diagnosis_events" colspan="4"/>
|
||||
<group id="abort_and_farrowing" colspan="4" col="6">
|
||||
<label name="abort_event"/>
|
||||
<field name="abort_event"/>
|
||||
<newline/>
|
||||
<label name="farrowing_event"/>
|
||||
<field name="farrowing_event"/>
|
||||
<label name="live"/>
|
||||
<field name="live"/>
|
||||
<label name="dead"/>
|
||||
<field name="dead"/>
|
||||
</group>
|
||||
<field name="foster_events" colspan="4"/>
|
||||
<newline/>
|
||||
<label name="weaning_event"/>
|
||||
<field name="weaning_event"/>
|
||||
<label name="weaned"/>
|
||||
<field name="weaned"/>
|
||||
</page>
|
||||
<page id="observations" string="Observations">
|
||||
<label name="observations"/>
|
||||
<field name="observations"/>
|
||||
</page>
|
||||
</notebook>
|
||||
</form>
|
||||
|
|
|
@ -68,6 +68,7 @@
|
|||
<label name="last_produced_group"/>
|
||||
<field name="last_produced_group"/>
|
||||
</group>
|
||||
<button name="change_observation" string="Change Cycle Observation"/>
|
||||
</page>
|
||||
<page string="Weights" id="weights">
|
||||
<label name="current_weight"/>
|
||||
|
|
Loading…
Reference in New Issue