Add current user farms into context when validating moves

This commit is contained in:
Sergi Carol 2017-07-04 11:00:06 +02:00
parent 2ef678909d
commit 749efd334a
1 changed files with 3 additions and 1 deletions

View File

@ -54,7 +54,9 @@ class MoveEvent:
cls.raise_user_error('weight_required_in_sale_move_event',
(event.rec_name,))
sales_to_process.add(event.origin.sale.id)
with Transaction().set_user(0, set_context=True):
user_farms = Transaction().context.get('farms')
with Transaction().set_user(0, set_context=True), \
Transaction().set_context(farms=user_farms):
super(MoveEvent, cls).validate_event(events)
if sales_to_process:
Sale.process(Sale.browse(list(sales_to_process)))