[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#61522

X-original-commit: c1fccaee5dd676f2fe07bb5c17eb2967ee6b742e
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
This commit is contained in:
Nicolas Martinelli
2020-11-09 10:01:37 +00:00
parent 682650a57e
commit 63d5102a2e
+12
View File
@@ -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]: