From 6ba24a4137136347319f9e1135f4fdd4f65053fb Mon Sep 17 00:00:00 2001 From: Swapnesh Shah Date: Sat, 10 Oct 2020 06:40:32 +0000 Subject: [PATCH] [FIX] sale_stock: inventory widget visibility Before this commit there would be crash on Removing `Unit` field from Sale order lines list view due to missing `product_uom`, Which is necessary for `QtyAtDateWidget` widget. Now we hide the Widget if `product_uom` is not selected. Fixes #59492 closes odoo/odoo#59724 X-original-commit: ea798c07d31fd186af4bf851966f791a96cb13fd Signed-off-by: Arnold Moyaux --- addons/sale_stock/models/sale_order.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/sale_stock/models/sale_order.py b/addons/sale_stock/models/sale_order.py index a54942de926..36725eab789 100644 --- a/addons/sale_stock/models/sale_order.py +++ b/addons/sale_stock/models/sale_order.py @@ -277,12 +277,12 @@ class SaleOrderLine(models.Model): is_mto = fields.Boolean(compute='_compute_is_mto') display_qty_widget = fields.Boolean(compute='_compute_qty_to_deliver') - @api.depends('product_type', 'product_uom_qty', 'qty_delivered', 'state', 'move_ids') + @api.depends('product_type', 'product_uom_qty', 'qty_delivered', 'state', 'move_ids', 'product_uom') def _compute_qty_to_deliver(self): """Compute the visibility of the inventory widget.""" for line in self: line.qty_to_deliver = line.product_uom_qty - line.qty_delivered - if line.state in ('draft', 'sent', 'sale') and line.product_type == 'product' and line.qty_to_deliver > 0: + if line.state in ('draft', 'sent', 'sale') and line.product_type == 'product' and line.product_uom and line.qty_to_deliver > 0: if line.state == 'sale' and not line.move_ids: line.display_qty_widget = False else: