diff --git a/addons/sale_stock/models/sale_order.py b/addons/sale_stock/models/sale_order.py index 8e62094dea9..63fd29d4710 100644 --- a/addons/sale_stock/models/sale_order.py +++ b/addons/sale_stock/models/sale_order.py @@ -207,7 +207,7 @@ class SaleOrderLine(models.Model): scheduled_date = fields.Datetime(compute='_compute_qty_at_date') free_qty_today = fields.Float(compute='_compute_qty_at_date') qty_available_today = fields.Float(compute='_compute_qty_at_date') - warehouse_id = fields.Many2one(related='order_id.warehouse_id') + warehouse_id = fields.Many2one('stock.warehouse', compute='_compute_qty_at_date') qty_to_deliver = fields.Float(compute='_compute_qty_to_deliver') is_mto = fields.Boolean(compute='_compute_is_mto') display_qty_widget = fields.Boolean(compute='_compute_qty_to_deliver') @@ -236,13 +236,13 @@ class SaleOrderLine(models.Model): for line in self: if not line.display_qty_widget: continue - warehouse = line.order_id.warehouse_id + line.warehouse_id = line.order_id.warehouse_id if line.order_id.commitment_date: date = line.order_id.commitment_date else: confirm_date = line.order_id.date_order if line.order_id.state in ['sale', 'done'] else datetime.now() date = confirm_date + timedelta(days=line.customer_lead or 0.0) - grouped_lines[(warehouse.id, date)] |= line + grouped_lines[(line.warehouse_id.id, date)] |= line treated = self.browse() for (warehouse, scheduled_date), lines in grouped_lines.items(): @@ -268,6 +268,7 @@ class SaleOrderLine(models.Model): remaining.scheduled_date = False remaining.free_qty_today = False remaining.qty_available_today = False + remaining.warehouse_id = False @api.depends('product_id', 'route_id', 'order_id.warehouse_id', 'product_id.route_ids') def _compute_is_mto(self): diff --git a/addons/sale_stock/static/src/js/qty_at_date_widget.js b/addons/sale_stock/static/src/js/qty_at_date_widget.js index db168822008..df3d60e8002 100644 --- a/addons/sale_stock/static/src/js/qty_at_date_widget.js +++ b/addons/sale_stock/static/src/js/qty_at_date_widget.js @@ -35,6 +35,16 @@ var QtyAtDateWidget = Widget.extend({ self._setPopOver(); }); }, + + updateState: function (state) { + this.$el.popover('dispose'); + var candidate = state.data[this.getParent().currentRow]; + if (candidate) { + this.data = candidate.data; + this.renderElement(); + this._setPopOver(); + } + }, //-------------------------------------------------------------------------- // Private //-------------------------------------------------------------------------- @@ -58,7 +68,7 @@ var QtyAtDateWidget = Widget.extend({ var $forecastButton = $content.find('.action_open_forecast'); $forecastButton.on('click', function(ev) { ev.stopPropagation(); - data_manager.load_action('stock.report_stock_quantity_action').then(function (action) { + data_manager.load_action('stock.report_stock_quantity_action_product').then(function (action) { // Change action context to choose a specific date and product(s) // As grid_anchor is set to now() by default in the data, we need // to load the action first, change the context then launch it via do_action diff --git a/addons/sale_stock/static/src/xml/qty_at_date.xml b/addons/sale_stock/static/src/xml/qty_at_date.xml index beed0fe0325..be9e3bf7987 100644 --- a/addons/sale_stock/static/src/xml/qty_at_date.xml +++ b/addons/sale_stock/static/src/xml/qty_at_date.xml @@ -1,6 +1,6 @@
-
+
@@ -13,30 +13,23 @@
- - - - - + - - - - - - - - - - + + + + + + + +

This product is replenished on demand.

@@ -46,7 +39,7 @@ diff --git a/addons/sale_stock/views/sale_order_views.xml b/addons/sale_stock/views/sale_order_views.xml index d342368fb84..c07975c1415 100644 --- a/addons/sale_stock/views/sale_order_views.xml +++ b/addons/sale_stock/views/sale_order_views.xml @@ -92,7 +92,7 @@ - +
Expected Delivery
Forecasted StockForecasted Stock
On
Stock On Hand -
Stock Available
On Hand - Reserved
-
Available
All planned operations included
+
Expected Delivery