The check for an animal with the same number now is done in the whole farm
This commit is contained in:
parent
1f61eeff09
commit
1d4645646d
14
animal.py
14
animal.py
|
@ -836,15 +836,18 @@ class Female:
|
|||
|
||||
@classmethod
|
||||
def create(cls, vlist):
|
||||
Animal = Pool().get('farm.animal')
|
||||
pool = Pool()
|
||||
Animal = pool.get('farm.animal')
|
||||
Location = pool.get('stock.location')
|
||||
for vals in vlist:
|
||||
if vals.get('type', '') == 'female' and not vals.get('state'):
|
||||
vals['state'] = 'prospective'
|
||||
number = vals.get('number')
|
||||
initial_location = vals.get('initial_location')
|
||||
location = Location(initial_location)
|
||||
|
||||
duplicate = Animal.search([('number', '=', number),
|
||||
('location', '=', initial_location),
|
||||
('farm', '=', location.warehouse.id),
|
||||
('active', '=', True)], limit=1)
|
||||
|
||||
if duplicate:
|
||||
|
@ -861,11 +864,12 @@ class Female:
|
|||
continue
|
||||
|
||||
for female in females:
|
||||
location = female.location
|
||||
farm = female.farm
|
||||
|
||||
duplicate = Animal.search([('number', '=', number),
|
||||
('location', '=', location),
|
||||
('active', '=', True)], limit=1)
|
||||
('farm', '=', farm),
|
||||
('active', '=', True),
|
||||
('id', '!=', female.id)], limit=1)
|
||||
if duplicate:
|
||||
cls.raise_user_error('duplicate_animal', number)
|
||||
|
||||
|
|
|
@ -20,8 +20,8 @@ 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"
|
||||
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 ""
|
||||
|
|
Loading…
Reference in New Issue