diff options
| author | Nicolas Martinelli <nim@odoo.com> | 2020-11-05 12:33:33 +0000 |
|---|---|---|
| committer | Nicolas Martinelli <nim@odoo.com> | 2020-11-09 08:27:53 +0000 |
| commit | c1fccaee5dd676f2fe07bb5c17eb2967ee6b742e (patch) | |
| tree | 075d1b11730bf4cb59c289fb7d7f894c41df01d5 | |
| parent | adc6af4aeba7fb5ef43c30714d73e4b9401dc536 (diff) | |
[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) <nim@odoo.com>
| -rw-r--r-- | addons/sale_mrp/models/sale.py | 12 |
1 files changed, 12 insertions, 0 deletions
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]: |
