[FIX] stock: display forecast btn only for product

The `forecast_widget` will display the forecast report button only for
lines with a storable product.

closes odoo/odoo#55826

Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
This commit is contained in:
svs-odoo
2020-08-20 15:32:14 +00:00
parent 1d256d7a7c
commit 8a7cf5045f
2 changed files with 6 additions and 7 deletions
+4 -7
View File
@@ -412,15 +412,12 @@ class StockMove(models.Model):
return
# compute
precision = self.env['decimal.precision'].precision_get('Product Unit of Measure')
consu_moves = self.filtered(lambda move: move.product_id.type == 'consu')
for move in consu_moves:
not_product_moves = self.filtered(lambda move: move.product_id.type == 'product')
for move in not_product_moves:
reserved_availability = float_repr(move.reserved_availability, precision)
move.json_forecast = json.dumps({
'reservedAvailability': reserved_availability,
'hideReportButton': True,
})
move.json_forecast = json.dumps({'reservedAvailability': reserved_availability})
outgoing_unreserved_moves_per_warehouse = defaultdict(lambda: self.env['stock.move'])
for move in (self - consu_moves):
for move in (self - not_product_moves):
picking_type = move.picking_type_id or move.picking_id.picking_type_id
is_unreserved = float_is_zero(move.reserved_availability, precision_rounding=move.product_uom.rounding)
if picking_type.code in self._consuming_picking_types():
@@ -14,6 +14,8 @@ const ForecastWidgetField = AbstractField.extend({
if (!forecastData) {
this.$el.html('');
} else {
// Don't display the graph button for non-storable products or if was explicited.
forecastData.hideReportButton = this.recordData.product_type !== 'product';
this.$el.html(QWeb.render('stock.forecastWidget', forecastData));
this.$el.on('click', this._onOpenReport.bind(this));
}