From c1fccaee5dd676f2fe07bb5c17eb2967ee6b742e Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Thu, 5 Nov 2020 12:33:33 +0000 Subject: [FIX] sale_mrp: display of the forecast widget Hide the forecast widget in case of kits. Indeed: - the forecast report doesn't support kits - the semantic for a kit forecast is far from being obvious, especially in case of partial deliveries, returns, returns of returns, etc. Better hide it than displaying an incorrect information. closes odoo/odoo#61058 Signed-off-by: Nicolas Martinelli (nim) --- addons/sale_mrp/models/sale.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/addons/sale_mrp/models/sale.py b/addons/sale_mrp/models/sale.py index 22894b08b30..8e1c9704287 100644 --- a/addons/sale_mrp/models/sale.py +++ b/addons/sale_mrp/models/sale.py @@ -46,6 +46,18 @@ class SaleOrderLine(models.Model): """The inventory widget should now be visible in more cases if the product is consumable.""" super(SaleOrderLine, self)._compute_qty_to_deliver() for line in self: + # Hide the widget for kits since forecast doesn't support them. + boms = self.env['mrp.bom'] + if line.state == 'sale': + boms = line.move_ids.mapped('bom_line_id.bom_id') + elif line.state in ['draft', 'sent'] and line.product_id: + boms = boms._bom_find(product=line.product_id, company_id=line.company_id.id, bom_type='phantom') + relevant_bom = boms.filtered(lambda b: b.type == 'phantom' and + (b.product_id == line.product_id or + (b.product_tmpl_id == line.product_id.product_tmpl_id and not b.product_id))) + if relevant_bom: + line.display_qty_widget = False + continue if line.state == 'draft' and line.product_type == 'consu': components = line.product_id.get_components() if components and components != [line.product_id.id]: -- cgit v1.2.3