From 96fd02b7f343618f8b7792b03d080ffa015ad66f Mon Sep 17 00:00:00 2001 From: Patrick Wilson <36892066+patrickrwilson@users.noreply.github.com> Date: Mon, 23 Mar 2020 11:01:45 -0500 Subject: [PATCH] [IMP] Warehouse On Change Since the location and routes depend on the warehouse that is selected on the stock request order, if the warehouse changes then so will the route options. This adds an on change event so if the warehouse changes, then the direction gets cleared and so do the routes on the product lines. This forces the user to properly reset the items using the correct routes for the newly selected warehouse. --- stock_request_direction/models/stock_request_order.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/stock_request_direction/models/stock_request_order.py b/stock_request_direction/models/stock_request_order.py index 309261ea0..aa492e3e4 100644 --- a/stock_request_direction/models/stock_request_order.py +++ b/stock_request_direction/models/stock_request_order.py @@ -24,6 +24,14 @@ class StockRequestOrder(models.Model): self.location_id = \ self.warehouse_id.lot_stock_id.id + @api.onchange('warehouse_id') + def _onchange_warehouse_id(self): + if self.direction: + self.direction = False + for stock_request in self.stock_request_ids: + if stock_request.route_id: + stock_request.route_id = False + def change_childs(self): super().change_childs() if not self._context.get('no_change_childs', False):