[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 <amoyaux@users.noreply.github.com>
This commit is contained in:
Swapnesh Shah
2020-10-12 09:29:09 +00:00
committed by GitHub
parent 0fa5fe59a2
commit 6ba24a4137
+2 -2
View File
@@ -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: