fix consider operations

This commit is contained in:
lreficent
2017-12-27 15:36:43 +01:00
parent a7c850e27d
commit c5bbee161e

View File

@@ -17,6 +17,12 @@ class StockMove(models.Model):
return self.reserved_quant_ids.mapped('location_id') + \
self.split_from.reserved_quant_ids.mapped('location_id')
@api.multi
def _get_dest_locations(self):
self.ensure_one()
return self.linked_move_operation_ids.mapped(
'operation_id.location_dest_id')
@api.constrains('location_dest_id', 'location_id', 'state')
def _check_locked_location(self):
for move in self.filtered(lambda m: m.state != 'draft'):
@@ -24,10 +30,12 @@ class StockMove(models.Model):
'stock.inventory']._get_locations_open_inventories(
[move.location_dest_id.id, move.location_id.id])
reserved_locs = move._get_reserved_locations()
dest_locs = move._get_dest_locations()
if (locked_location_ids and
move.product_id.property_stock_inventory not in [
move.location_dest_id, move.location_id] and
(move.location_dest_id in locked_location_ids or
any([l in locked_location_ids for l in dest_locs]) or
any([l in locked_location_ids for l in reserved_locs]))):
location_names = locked_location_ids.mapped('complete_name')
raise ValidationError(