diff --git a/CHANGELOG b/CHANGELOG index c1f6eb840e..4622de6a0c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Allow to use view location on staging and draft moves * Add picking location on warehouse * Always compute expected quantity in inventory * Allow to change the destination of internal shipment's moves diff --git a/location.py b/location.py index 3f849e4937..0fa991b14e 100644 --- a/location.py +++ b/location.py @@ -85,7 +85,7 @@ class Location(ModelSQL, ModelView): 'required': Eval('type') == 'warehouse', }, domain=[ - ('type', '=', 'storage'), + ('type', 'in', ['storage', 'view']), ['OR', ('parent', 'child_of', [Eval('id')]), ('parent', '=', None)]], @@ -175,9 +175,12 @@ class Location(ModelSQL, ModelView): invalid_move_types = ['warehouse', 'view'] Move = Pool().get('stock.move') if (self.type in invalid_move_types - and Move.search(['OR', - ('to_location', '=', self.id), - ('from_location', '=', self.id), + and Move.search([ + ['OR', + ('to_location', '=', self.id), + ('from_location', '=', self.id), + ], + ('state', 'not in', ['staging', 'draft']), ])): self.raise_user_error('invalid_type_for_moves', (self.rec_name,)) diff --git a/move.py b/move.py index dbe928798e..de9d098025 100644 --- a/move.py +++ b/move.py @@ -25,6 +25,12 @@ STATES = { 'readonly': Eval('state').in_(['cancel', 'assigned', 'done']), } DEPENDS = ['state'] +LOCATION_DOMAIN = [ + If(Eval('state').in_(['staging', 'draft']), + ('type', 'not in', ['warehouse']), + ('type', 'not in', ['warehouse', 'view'])), + ] +LOCATION_DEPENDS = ['state'] class StockMixin: @@ -174,11 +180,11 @@ class Move(Workflow, ModelSQL, ModelView): internal_quantity = fields.Float('Internal Quantity', readonly=True, required=True) from_location = fields.Many2One("stock.location", "From Location", - select=True, required=True, states=STATES, depends=DEPENDS, - domain=[('type', 'not in', ('warehouse', 'view'))]) + select=True, required=True, states=STATES, + depends=DEPENDS + LOCATION_DEPENDS, domain=LOCATION_DOMAIN) to_location = fields.Many2One("stock.location", "To Location", select=True, - required=True, states=STATES, depends=DEPENDS, - domain=[('type', 'not in', ('warehouse', 'view'))]) + required=True, states=STATES, + depends=DEPENDS + LOCATION_DEPENDS, domain=LOCATION_DOMAIN) shipment = fields.Reference('Shipment', selection='get_shipment', readonly=True, select=True) origin = fields.Reference('Origin', selection='get_origin', select=True, diff --git a/shipment.py b/shipment.py index 1d163b4388..96610e17eb 100644 --- a/shipment.py +++ b/shipment.py @@ -505,7 +505,7 @@ class ShipmentInReturn(Workflow, ModelSQL, ModelView): from_location = fields.Many2One('stock.location', "From Location", required=True, states={ 'readonly': (Eval('state') != 'draft') | Eval('moves', [0]), - }, domain=[('type', '=', 'storage')], + }, domain=[('type', 'in', ['storage', 'view'])], depends=['state']) to_location = fields.Many2One('stock.location', "To Location", required=True, states={ @@ -1771,13 +1771,13 @@ class ShipmentInternal(Workflow, ModelSQL, ModelView): 'readonly': (Eval('state') != 'draft') | Eval('moves', [0]), }, domain=[ - ('type', 'in', ['storage', 'lost_found']), + ('type', 'in', ['view', 'storage', 'lost_found']), ], depends=['state']) to_location = fields.Many2One('stock.location', "To Location", required=True, states={ 'readonly': (Eval('state') != 'draft') | Eval('moves', [0]), }, domain=[ - ('type', 'in', ['storage', 'lost_found']), + ('type', 'in', ['view', 'storage', 'lost_found']), ], depends=['state']) moves = fields.One2Many('stock.move', 'shipment', 'Moves', states={