From ca9a12ff2a14bff033ca77b9a34e42a4b3e3525c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Voet=20=28ryv=29?= Date: Thu, 15 Oct 2020 08:27:44 +0000 Subject: [PATCH] [FIX] sale_stock: fix color forecasted popover Before, the `virtual_available_at_date` was used to describe the `free_qty_today` when the forecasted is calculated via the forecasted of stock move. This issue create a difference of color when SO become confirmed (if the `free_qty_today < 0`). To fix this, use the `free_qty_today` to compute the `will_be_fulfilled` (in the js widget) and fill `free_qty_today` instead of `virtual_available_at_date` when SO is confirmed. opw-2360024 closes odoo/odoo#60072 X-original-commit: 94c10df77643ad9a7806c4967911717692db91ce Signed-off-by: Arnold Moyaux --- addons/sale_stock/models/sale_order.py | 8 ++++---- addons/sale_stock/static/src/js/qty_at_date_widget.js | 2 +- addons/sale_stock/static/src/xml/sale_stock.xml | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/addons/sale_stock/models/sale_order.py b/addons/sale_stock/models/sale_order.py index 36725eab789..b805e6a9137 100644 --- a/addons/sale_stock/models/sale_order.py +++ b/addons/sale_stock/models/sale_order.py @@ -270,7 +270,7 @@ class SaleOrderLine(models.Model): virtual_available_at_date = fields.Float(compute='_compute_qty_at_date', digits='Product Unit of Measure') scheduled_date = fields.Datetime(compute='_compute_qty_at_date') forecast_expected_date = fields.Datetime(compute='_compute_qty_at_date') - free_qty_today = fields.Float(compute='_compute_qty_at_date') + free_qty_today = fields.Float(compute='_compute_qty_at_date', digits='Product Unit of Measure') qty_available_today = fields.Float(compute='_compute_qty_at_date') warehouse_id = fields.Many2one(related='order_id.warehouse_id') qty_to_deliver = fields.Float(compute='_compute_qty_to_deliver', digits='Product Unit of Measure') @@ -308,12 +308,12 @@ class SaleOrderLine(models.Model): moves = line.move_ids line.forecast_expected_date = max(moves.filtered("forecast_expected_date").mapped("forecast_expected_date"), default=False) line.qty_available_today = 0 - line.virtual_available_at_date = 0 + line.free_qty_today = 0 for move in moves: line.qty_available_today += move.product_uom._compute_quantity(move.reserved_availability, line.product_uom) - line.virtual_available_at_date += move.product_id.uom_id._compute_quantity(move.forecast_availability, line.product_uom) + line.free_qty_today += move.product_id.uom_id._compute_quantity(move.forecast_availability, line.product_uom) line.scheduled_date = line.order_id.commitment_date or line._expected_date() - line.free_qty_today = False + line.virtual_available_at_date = False treated |= line qty_processed_per_product = defaultdict(lambda: 0) 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 1db241af638..375d607cc5f 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 @@ -39,7 +39,7 @@ var QtyAtDateWidget = Widget.extend({ _updateData: function() { // add some data to simplify the template if (this.data.scheduled_date) { - this.data.will_be_fulfilled = utils.round_decimals(this.data.virtual_available_at_date, this.fields.virtual_available_at_date.digits[1]) >= utils.round_decimals(this.data.qty_to_deliver, this.fields.qty_to_deliver.digits[1]); + this.data.will_be_fulfilled = utils.round_decimals(this.data.free_qty_today, this.fields.free_qty_today.digits[1]) >= utils.round_decimals(this.data.qty_to_deliver, this.fields.qty_to_deliver.digits[1]); this.data.will_be_late = this.data.forecast_expected_date && this.data.forecast_expected_date > this.data.scheduled_date; if (['draft', 'sent'].includes(this.data.state)){ // Moves aren't created yet, then the forecasted is only based on virtual_available of quant diff --git a/addons/sale_stock/static/src/xml/sale_stock.xml b/addons/sale_stock/static/src/xml/sale_stock.xml index 5fb2646f92f..23b85b3b398 100644 --- a/addons/sale_stock/static/src/xml/sale_stock.xml +++ b/addons/sale_stock/static/src/xml/sale_stock.xml @@ -16,7 +16,7 @@ Available
All planned operations included - +