Add default value for breed on animal and animal group
This commit is contained in:
parent
cdbac8ee0f
commit
9a0031604f
10
animal.py
10
animal.py
|
@ -233,6 +233,16 @@ class Animal(ModelSQL, ModelView, AnimalMixin):
|
|||
def default_specie():
|
||||
return Transaction().context.get('specie')
|
||||
|
||||
@staticmethod
|
||||
def default_breed():
|
||||
pool = Pool()
|
||||
Specie = pool.get('farm.specie')
|
||||
context = Transaction().context
|
||||
if 'specie' in context:
|
||||
specie = Specie(context['specie'])
|
||||
if len(specie.breeds) == 1:
|
||||
return specie.breeds[0].id
|
||||
|
||||
@staticmethod
|
||||
def default_type():
|
||||
return Transaction().context.get('animal_type')
|
||||
|
|
|
@ -126,6 +126,16 @@ class AnimalGroup(ModelSQL, ModelView, AnimalMixin):
|
|||
def default_specie():
|
||||
return Transaction().context.get('specie')
|
||||
|
||||
@staticmethod
|
||||
def default_breed():
|
||||
pool = Pool()
|
||||
Specie = pool.get('farm.specie')
|
||||
context = Transaction().context
|
||||
if 'specie' in context:
|
||||
specie = Specie(context['specie'])
|
||||
if len(specie.breeds) == 1:
|
||||
return specie.breeds[0].id
|
||||
|
||||
@staticmethod
|
||||
def default_origin():
|
||||
return 'purchased'
|
||||
|
|
Loading…
Reference in New Issue