The check for an animal with the same number now is done in the whole farm

This commit is contained in:
Sergi Carol 2017-05-11 14:25:09 +02:00
parent 1f61eeff09
commit 1d4645646d
2 changed files with 11 additions and 7 deletions

View File

@ -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)

View File

@ -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 ""