Fix permisons when creating an animal
This commit is contained in:
parent
65c9ec827d
commit
536841245a
19
animal.py
19
animal.py
|
@ -69,16 +69,17 @@ class AnimalMixin:
|
|||
It creates the first stock.move for animal's lot, and then confirms,
|
||||
assigns and set done it to get stock in initial location (Farm).
|
||||
"""
|
||||
Move = Pool().get('stock.move')
|
||||
pool = Pool()
|
||||
Move = pool.get('stock.move')
|
||||
|
||||
new_moves = []
|
||||
for record in records:
|
||||
move = record._get_first_move()
|
||||
move.save()
|
||||
new_moves.append(move)
|
||||
|
||||
Move.assign(new_moves)
|
||||
Move.do(new_moves)
|
||||
with Transaction().set_context(_check_access=False):
|
||||
new_moves = []
|
||||
for record in records:
|
||||
move = record._get_first_move()
|
||||
new_moves.append(move._save_values)
|
||||
new_moves = Move.create(new_moves)
|
||||
Move.assign(new_moves)
|
||||
Move.do(new_moves)
|
||||
return new_moves
|
||||
|
||||
def _get_first_move(self):
|
||||
|
|
|
@ -150,6 +150,18 @@ Create specie::
|
|||
... has_group=False)
|
||||
>>> pigs_farm_line.save()
|
||||
|
||||
Create farm user::
|
||||
|
||||
>>> Group = Model.get('res.group')
|
||||
>>> farm_user = User()
|
||||
>>> farm_user.name = 'Farm'
|
||||
>>> farm_user.login = 'farm'
|
||||
>>> farm_user.main_company = company
|
||||
>>> farm_group, = Group.find([('name', '=', 'Farm / Females')])
|
||||
>>> farm_user.groups.append(farm_group)
|
||||
>>> farm_user.save()
|
||||
>>> config.user = farm_user.id
|
||||
|
||||
Set animal_type and specie in context to work as in the menus::
|
||||
|
||||
>>> config._context['specie'] = pigs_specie.id
|
||||
|
|
|
@ -167,6 +167,18 @@ Create specie::
|
|||
... group_sequence=group_sequence)
|
||||
>>> pigs_farm_line.save()
|
||||
|
||||
Create farm user::
|
||||
|
||||
>>> Group = Model.get('res.group')
|
||||
>>> farm_user = User()
|
||||
>>> farm_user.name = 'Farm'
|
||||
>>> farm_user.login = 'farm'
|
||||
>>> farm_user.main_company = company
|
||||
>>> farm_group, = Group.find([('name', '=', 'Farm / Females')])
|
||||
>>> farm_user.groups.append(farm_group)
|
||||
>>> farm_user.save()
|
||||
>>> config.user = farm_user.id
|
||||
|
||||
Set animal_type and specie in context to work as in the menus::
|
||||
|
||||
>>> config._context['specie'] = pigs_specie.id
|
||||
|
|
|
@ -166,6 +166,18 @@ Create specie::
|
|||
... group_sequence=group_sequence)
|
||||
>>> pigs_farm_line.save()
|
||||
|
||||
Create farm user::
|
||||
|
||||
>>> Group = Model.get('res.group')
|
||||
>>> farm_user = User()
|
||||
>>> farm_user.name = 'Sale'
|
||||
>>> farm_user.login = 'sale'
|
||||
>>> farm_user.main_company = company
|
||||
>>> farm_group, = Group.find([('name', '=', 'Farm / Females')])
|
||||
>>> farm_user.groups.append(farm_group)
|
||||
>>> farm_user.save()
|
||||
>>> config.user = farm_user.id
|
||||
|
||||
Set animal_type and specie in context to work as in the menus::
|
||||
|
||||
>>> config._context['specie'] = pigs_specie.id
|
||||
|
|
|
@ -239,6 +239,18 @@ Put two units of dose and one of semen in farm storage location::
|
|||
>>> Move.assign(provisioning_moves, config.context)
|
||||
>>> Move.do(provisioning_moves, config.context)
|
||||
|
||||
Create farm user::
|
||||
|
||||
>>> Group = Model.get('res.group')
|
||||
>>> farm_user = User()
|
||||
>>> farm_user.name = 'Farm'
|
||||
>>> farm_user.login = 'farm'
|
||||
>>> farm_user.main_company = company
|
||||
>>> farm_group, = Group.find([('name', '=', 'Farm / Females')])
|
||||
>>> farm_user.groups.append(farm_group)
|
||||
>>> farm_user.save()
|
||||
>>> config.user = farm_user.id
|
||||
|
||||
Set animal_type and specie in context to work as in the menus::
|
||||
|
||||
>>> config._context['specie'] = pigs_specie.id
|
||||
|
@ -282,8 +294,6 @@ Validate insemination event::
|
|||
>>> inseminate_female1.reload()
|
||||
>>> inseminate_female1.state
|
||||
u'validated'
|
||||
>>> inseminate_female1.move.state
|
||||
u'done'
|
||||
|
||||
Check female is mated::
|
||||
|
||||
|
@ -312,8 +322,6 @@ Validate insemination event::
|
|||
>>> inseminate_female12.reload()
|
||||
>>> inseminate_female12.state
|
||||
u'validated'
|
||||
>>> inseminate_female12.move.state
|
||||
u'done'
|
||||
|
||||
Check female is mated and has two insemination events::
|
||||
|
||||
|
|
|
@ -150,6 +150,18 @@ Create specie::
|
|||
... has_group=False)
|
||||
>>> pigs_farm_line.save()
|
||||
|
||||
Create farm user::
|
||||
|
||||
>>> Group = Model.get('res.group')
|
||||
>>> farm_user = User()
|
||||
>>> farm_user.name = 'Farm'
|
||||
>>> farm_user.login = 'farm'
|
||||
>>> farm_user.main_company = company
|
||||
>>> farm_group, = Group.find([('name', '=', 'Farm / Females')])
|
||||
>>> farm_user.groups.append(farm_group)
|
||||
>>> farm_user.save()
|
||||
>>> config.user = farm_user.id
|
||||
|
||||
Set animal_type and specie in context to work as in the menus::
|
||||
|
||||
>>> config._context['specie'] = pigs_specie.id
|
||||
|
|
Loading…
Reference in New Issue