From 0bc2d19747ff10363b12d949454d22e4326f2336 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Mon, 21 Nov 2016 18:17:24 +0100 Subject: [PATCH] Add direct access to re-ordering rules from stock location --- stock_usability/stock.py | 14 ++++++++++++++ stock_usability/stock_view.xml | 19 +++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/stock_usability/stock.py b/stock_usability/stock.py index 39a5657..fd9e699 100644 --- a/stock_usability/stock.py +++ b/stock_usability/stock.py @@ -49,6 +49,20 @@ class StockLocationRoute(models.Model): class StockWarehouseOrderpoint(models.Model): _inherit = 'stock.warehouse.orderpoint' + # This is for the button shortcut "reordering rules" on + # stock.location form view, so that the location_id has the + # good value, not the default stock location of the first WH of the company + @api.model + def default_get(self, fields): + res = {} + if self._context.get('default_location_id'): + location = self.env['stock.location'].browse( + self._context['default_location_id']) + wh = location.get_warehouse() + if location and wh: + self = self.with_context(default_warehouse_id=wh.id) + return super(StockWarehouseOrderpoint, self).default_get(fields) + # This SQL constraint blocks the use of the "active" field # but I think it's not very useful to have such an "active" field # on orderpoints ; when you think the order point is bad, you update diff --git a/stock_usability/stock_view.xml b/stock_usability/stock_view.xml index 270ceed..737eb1a 100644 --- a/stock_usability/stock_view.xml +++ b/stock_usability/stock_view.xml @@ -205,6 +205,25 @@ + + Reordering Rules + stock.warehouse.orderpoint + {'default_location_id': active_id, 'search_default_location_id': active_id} + + + + stock.usability.stock.location.form + stock.location + + + + + + stock.usability.quant.tree stock.quant