Fix search_rec_name, Cycle get_rec_name and weaning event form

* convert parameter clause to tuple before concatenating in search_rec_name of
  Animal and AnimalGroup
* calculate correctly the state label in get_rec_name of FemaleCycle
* replace second label of weaned_group by field in Weaning Event form view
This commit is contained in:
Guillem Barba 2013-09-27 13:47:11 +02:00
parent 4bc08c6efd
commit de1c8b250f
3 changed files with 9 additions and 8 deletions

View File

@ -242,7 +242,7 @@ class Animal(ModelSQL, ModelView, AnimalMixin):
@classmethod
def search_rec_name(cls, name, clause):
return [('lot.number',) + clause[1:]]
return [('lot.number',) + tuple(clause[1:])]
def get_number(self, name):
return self.lot.number
@ -827,10 +827,11 @@ class FemaleCycle(ModelSQL, ModelView):
return 'unmated'
def get_rec_name(self, name):
logging.getLogger(self.__name__).debug("FemaleCycle.get_rec_name()")
state_labels = FemaleCycle.state.selection
logging.getLogger(self.__name__).debug("state_labels: ", state_labels)
return "%s (%s)" % (self.sequence, state_labels[self.state])
state_labels = [label for (n, label) in FemaleCycle.state.selection
if n == self.state]
if state_labels:
return "%s (%s)" % (self.sequence, state_labels[0])
return "%s" % self.sequence
# TODO: call in weaning, farrowing, abort, pregnancy_diagnosis and
# insemination event (in 'valid()' and 'cancel()')
@ -916,7 +917,7 @@ class FemaleCycle(ModelSQL, ModelView):
def get_removed(self, name):
return self.live + self.fostered + self.weaned
def get_days_between_farrowing_weaning(self, name):
def get_lactating_days(self, name):
if not self.farrowing_event or not self.weaning_event:
return None
return (self.weaning_event.timestamp.date() -

View File

@ -127,7 +127,7 @@ class AnimalGroup(ModelSQL, ModelView, AnimalMixin):
@classmethod
def search_rec_name(cls, name, clause):
return [('lot.number',) + clause[1:]]
return [('lot.number',) + tuple(clause[1:])]
def get_number(self, name):
return self.lot.number

View File

@ -13,7 +13,7 @@
<label name="quantity"/>
<field name="quantity"/>
<label name="weaned_group"/>
<label name="weaned_group"/>
<field name="weaned_group"/>
<separator id="validated_fields" colspan="4"/>
<label name="female_cycle"/>
<field name="female_cycle"/>