[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 <amoyaux@users.noreply.github.com>
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Available</strong><br /><small>All planned operations included</small></td>
|
||||
<td><b t-esc='data.free_qty_today'/>
|
||||
<td><b t-esc='data.free_qty_today' t-att-class="!data.will_be_fulfilled ? 'text-danger': ''"/>
|
||||
<t t-esc='data.product_uom.data.display_name'/></td>
|
||||
</tr>
|
||||
</t>
|
||||
|
||||
Reference in New Issue
Block a user